-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathazure-pipelines.yml
310 lines (272 loc) · 13.3 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# Docker image
# Build a Docker image to deploy, run, or push to a container registry.
# Add steps that use Docker Compose, tag images, push to a registry, run an image, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/docker
# Everything must be under a 'job' to be able to set the timeoutInMinutes
jobs:
- job: "bootstrap_prepare_image"
timeoutInMinutes: 0
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_ci_prepare
steps:
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
# We divide the boostrap in 3 parts to not go over the 6h limit as gcc takes ages
- script: cd bootstrap_stage && docker build -f Dockerfile.prepare -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build prepare_image'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# The variables are set on the Build options on the web interface
# Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
condition: always()
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
condition: always()
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
condition: always()
- job: "bootstrap_stage_1"
timeoutInMinutes: 0
dependsOn: "bootstrap_prepare_image"
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_ci_stage1
steps:
# The variables are set on the Build options on the web interface
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
- script: cd bootstrap_stage && docker build -f Dockerfile.stage1 -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build stage_1'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# # Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
condition: always()
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
condition: always()
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
condition: always()
- job: "bootstrap_stage_2"
timeoutInMinutes: 0
dependsOn: "bootstrap_stage_1"
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_ci_stage2
steps:
# The variables are set on the Build options on the web interface
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
- script: cd bootstrap_stage && docker build -f Dockerfile.stage2 -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build stage_2'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# # Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
condition: always()
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
condition: always()
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
condition: always()
- job: "bootstrap_stage_3"
timeoutInMinutes: 0
dependsOn: "bootstrap_stage_2"
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_ci_stage3
steps:
# The variables are set on the Build options on the web interface
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
- script: cd bootstrap_stage && docker build -f Dockerfile.stage3 -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build stage_3'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# # Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
condition: always()
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
condition: always()
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
condition: always()
- job: "bootstrap_emerge_system"
timeoutInMinutes: 0
dependsOn: "bootstrap_stage_3"
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_ci_emerge_system
steps:
# The variables are set on the Build options on the web interface
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
- script: cd bootstrap_stage && docker build -f Dockerfile.emergesystem -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build emerge_system'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# # Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
condition: always()
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
condition: always()
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
condition: always()
- job: package_stage
timeoutInMinutes: 0
dependsOn: "bootstrap_emerge_system"
pool:
vmImage: 'Ubuntu 20.04'
variables:
docker_image_name: gentoo_prefix_latest_image_package_stage
platform: amd64
steps:
# The variables are set on the Build options on the web interface
- script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
displayName: 'docker login'
- script: cd package_stage && docker build -f Dockerfile -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
displayName: 'docker build package_stage'
# This means up to 6h
timeoutInMinutes: 0
# Even if it fails I want to push the image to DockerHub for inspection
# continueOnError: true
# # Try to tag the latest failed image we ran
- script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'create image to push to DockerHub'
condition: failed()
# Push it
- script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
displayName: 'push image to DockerHub'
# Tag as :latest too
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
displayName: 'tag as latest'
# Push as latest
- script: docker push $(DockerHub_user)/$(docker_image_name):latest
displayName: 'push latest to DockerHub'
# Create a more user-friendly image name
- script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/gentoo_prefix_boostrapped:latest
displayName: 'tag as gentoo_prefix_boostrapped:latest'
- script: docker push $(DockerHub_user)/gentoo_prefix_boostrapped:latest
displayName: 'push gentoo_prefix_boostrapped:latest to DockerHub'
# Extract the gentoo filesystem in a .tar.lzma for distribution
- script: docker run --entrypoint /tmp/gentoo/executeonprefix $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) "tar -c --lzma -f - -C /tmp gentoo" > ~/gentoo_on_tmp.tar.lzma
displayName: 'Create .tar.lzma of /tmp/gentoo'
# # Create a temporal container to copy the gentoo_on_tmp.tar.gz
# - script: |
# id=$(docker create $(DockerHub_user)/$(docker_image_name))
# docker cp $id:/tmp/gentoo_on_tmp.tar.gz $HOME
# displayName: 'Extract gentoo_on_tmp.tar.gz from Docker image'
# Not really needed
# - script: docker rm -v $id
# Make a release
# Use Python version
# Use the specified version of Python from the tool cache, optionally adding it to the PATH
- task: UsePythonVersion@0
inputs:
versionSpec: '3.7'
addToPath: true
- script: python3 -m pip install --upgrade pip setuptools wheel
displayName: 'Install tools'
- script: python3 -m pip install --user githubrelease
displayName: 'Install tools 2'
- script: |
export DATE=$(date -I'minutes' | sed 's/+/plus/g'| sed 's/:/at/g')
export RELEASE_TAG=release/${DATE}
export RELEASE_FILE_NAME=gentoo_on_tmp-${PLATFORM}_${DATE}.tar.lzma
export RELEASE_NAME="Gentoo Prefix on /tmp/gentoo"
export BODY="Use Gentoo Prefix with: tar xvf gentoo_on_tmp*.tar.lzma; ./gentoo/startprefix"
mv $HOME/gentoo_on_tmp.tar.lzma ${RELEASE_FILE_NAME}
export PATH=$HOME/.local/bin:$PATH
export PYTHONPATH=$HOME/.local/lib/python3.5/site-packages:$PYTHONPATH
githubrelease --github-token $(GitHub_Token) release $(Build.Repository.Name) create "${RELEASE_TAG}" --publish --name "${RELEASE_NAME}" --body "${BODY}" "${RELEASE_FILE_NAME}"
displayName: 'Create Release'
# - job: "bootstrap_on_fedora_rap_off"
# timeoutInMinutes: 0
# pool:
# vmImage: 'Ubuntu 16.04'
# variables:
# docker_image_name: gentoo_prefix_latest_image_initial_fedora
# steps:
# - script: docker login -u $(DockerHub_user) -p $(DockerHub_password)
# displayName: 'docker login'
# # We divide the boostrap in 3 parts to not go over the 6h limit as gcc takes ages
# - script: cd bootstrap_stage && docker build -f Dockerfile.fedora -t $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) .
# displayName: 'docker build'
# # This means up to 6h
# timeoutInMinutes: 0
# # Even if it fails I want to push the image to DockerHub for inspection
# # continueOnError: true
# # The variables are set on the Build options on the web interface
# # Try to tag the latest failed image we ran
# - script: docker tag `docker ps -a -l -q | xargs docker commit | awk -F":" '{print $2}'` $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
# displayName: 'create image to push to DockerHub'
# condition: failed()
# # Push it
# - script: docker push $(DockerHub_user)/$(docker_image_name):$(Build.BuildId)
# displayName: 'push image to DockerHub'
# condition: always()
# # Tag as :latest too
# - script: docker tag $(DockerHub_user)/$(docker_image_name):$(Build.BuildId) $(DockerHub_user)/$(docker_image_name):latest
# displayName: 'tag as latest'
# condition: always()
# # Push as latest
# - script: docker push $(DockerHub_user)/$(docker_image_name):latest
# displayName: 'push latest to DockerHub'
# condition: always()