4
4
workflow_dispatch :
5
5
push :
6
6
branches :
7
- - ' * '
7
+ - " ** "
8
8
pull_request :
9
9
branches :
10
- - ' main'
10
+ - " main"
11
11
12
12
env :
13
- IMAGE_BASE_NAME : ' throwtheswitch/madsciencelab'
13
+ IMAGE_ORG : ' throwtheswitch'
14
+ IMAGE_BASE_NAME : ' madsciencelab'
14
15
15
16
16
17
jobs :
17
18
# Jobs organized for concurrent Docker image builds
18
19
# Jobs only build :latest images without pushing to Docker Hub
19
20
21
+ # This is a workaround to the limitation that an `env:` map cannot reference the `env:` map to create additional environment variables
22
+ image-details :
23
+ runs-on : ubuntu-latest
24
+ steps :
25
+ # A step must be present in order to make use of `outputs:`
26
+ - run : echo "Setting Docker image details..."
27
+ outputs :
28
+ base-name : ' madsciencelab'
29
+ base-url : ' throwtheswitch/madsciencelab'
30
+
20
31
madsciencelab :
21
32
runs-on : ubuntu-latest
33
+ needs : [image-details]
22
34
permissions :
23
35
contents : read
24
36
packages : write
25
37
attestations : write
26
38
id-token : write
39
+ env :
40
+ IMAGE_NAME : ${{ needs.image-details.outputs.base-name }}
41
+ IMAGE_URL : ${{ needs.image-details.outputs.base-url }}
42
+ # Image variant name is drawn from final `--dir` entry in file generation command line
43
+ IMAGE_DIR : build/standard
27
44
28
45
steps :
46
+ - name : ' Set up Ruby for generation tool'
47
+ uses : ruby/setup-ruby@v1
48
+ with :
49
+ ruby-version : ' 3.3'
50
+ bundler-cache : true
51
+
29
52
- name : ' Checkout GitHub Action'
30
53
uses : actions/checkout@v4
31
54
55
+ - name : ' Install file generation Ruby dependencies'
56
+ run : bundle install
57
+
58
+ - name : ' Run file generation'
59
+ id : file-gen
60
+ run : bash build.sh --dir ${{ env.IMAGE_DIR }} --version dev
61
+
32
62
- name : ' Set up QEMU'
33
63
uses : docker/setup-qemu-action@v3
34
64
@@ -44,28 +74,61 @@ jobs:
44
74
45
75
# Docker image: madsciencelab
46
76
# Note: standard/ directory maps to madsciencelab image (no variants)
47
- - name : ' Build Docker image ${{ env.IMAGE_BASE_NAME }}'
77
+ - name : ' Build Docker image ${{ env.IMAGE_NAME }}'
48
78
uses : docker/build-push-action@v6
49
79
with :
50
80
platforms : linux/amd64,linux/arm64
51
- file : build/standard/docker/Dockerfile
52
- build-args : CONTAINER_VERSION=${{ github.ref_name }}
53
- tags : ${{ env.IMAGE_BASE_NAME }}:latest
81
+ context : .
82
+ file : ${{ env.IMAGE_DIR }}/docker/Dockerfile
83
+ build-args : |
84
+ CONTAINER_VERSION=${{ github.ref_name }}
85
+ IMAGE_NAME=${{ env.IMAGE_NAME }}
86
+ tags : ${{ env.IMAGE_URL }}:latest
87
+ # Connect Docker driver to GitHub Action cache service
88
+ cache-from : type=gha
89
+ cache-to : type=gha,mode=max
90
+
91
+ # Zip generated files as a single artifact
92
+ - name : ' Archive ${{ env.IMAGE_NAME }} generated files as a single artifact'
93
+ run : zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome
94
+
95
+ # Upload the zip artifact
96
+ - uses : actions/upload-artifact@v4
97
+ with :
98
+ name : ${{ env.IMAGE_NAME }}
99
+ path : ${{ env.IMAGE_NAME }}.zip
100
+ if-no-files-found : error
54
101
55
102
madsciencelab-plugins :
56
103
runs-on : ubuntu-latest
104
+ needs : [image-details]
57
105
permissions :
58
106
contents : read
59
107
packages : write
60
108
attestations : write
61
109
id-token : write
62
- env :
63
- VARIANT : plugins
110
+ env :
111
+ IMAGE_NAME : ${{ needs.image-details.outputs.base-name }}-plugins
112
+ IMAGE_URL : ${{ needs.image-details.outputs.base-url }}-plugins
113
+ # Image variant name is drawn from final `--dir` entry in file generation command line
114
+ IMAGE_DIR : build/plugins
64
115
65
116
steps :
117
+ - name : ' Set up Ruby for generation tool'
118
+ uses : ruby/setup-ruby@v1
119
+ with :
120
+ ruby-version : ' 3.3'
121
+ bundler-cache : true
122
+
66
123
- name : ' Checkout GitHub Action'
67
124
uses : actions/checkout@v4
68
125
126
+ - name : ' Install file generation Ruby dependencies'
127
+ run : bundle install
128
+
129
+ - name : ' Run file generation'
130
+ run : bash build.sh --dir build/standard --dir ${{ env.IMAGE_DIR }} --version dev
131
+
69
132
- name : ' Set up QEMU'
70
133
uses : docker/setup-qemu-action@v3
71
134
@@ -80,28 +143,61 @@ jobs:
80
143
password : ${{ secrets.DOCKERHUB_TOKEN }}
81
144
82
145
# Docker image: madsciencelab-plugins
83
- - name : ' Build Docker image ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}'
146
+ - name : ' Build Docker image ${{ env.IMAGE_NAME }}'
84
147
uses : docker/build-push-action@v6
85
148
with :
86
149
platforms : linux/amd64,linux/arm64
87
- file : build/${{ env.VARIANT }}/docker/Dockerfile
88
- build-args : CONTAINER_VERSION=${{ github.ref_name }}
89
- tags : ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}:latest
150
+ context : .
151
+ file : ${{ env.IMAGE_DIR }}/docker/Dockerfile
152
+ build-args : |
153
+ CONTAINER_VERSION=${{ github.ref_name }}
154
+ IMAGE_NAME=${{ env.IMAGE_NAME }}
155
+ tags : ${{ env.IMAGE_URL }}:latest
156
+ # Connect Docker driver to GitHub Action cache service
157
+ cache-from : type=gha
158
+ cache-to : type=gha,mode=max
159
+
160
+ # Zip generated files as a single artifact
161
+ - name : ' Archive ${{ env.IMAGE_NAME }} generated files as a single artifact'
162
+ run : zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome
163
+
164
+ # Upload the zip artifact
165
+ - uses : actions/upload-artifact@v4
166
+ with :
167
+ name : ${{ env.IMAGE_NAME }}
168
+ path : ${{ env.IMAGE_NAME }}.zip
169
+ if-no-files-found : error
90
170
91
171
madsciencelab-arm-none-eabi :
92
172
runs-on : ubuntu-latest
173
+ needs : [image-details]
93
174
permissions :
94
175
contents : read
95
176
packages : write
96
177
attestations : write
97
178
id-token : write
98
179
env :
99
- VARIANT : arm-none-eabi
180
+ IMAGE_NAME : ${{ needs.image-details.outputs.base-name }}-arm-none-eabi
181
+ IMAGE_URL : ${{ needs.image-details.outputs.base-url }}-arm-none-eabi
182
+ # Image variant name is drawn from final `--dir` entry in file generation command line
183
+ IMAGE_DIR : build/arm-none-eabi
100
184
101
185
steps :
186
+ - name : ' Set up Ruby for generation tool'
187
+ uses : ruby/setup-ruby@v1
188
+ with :
189
+ ruby-version : ' 3.3'
190
+ bundler-cache : true
191
+
102
192
- name : ' Checkout GitHub Action'
103
193
uses : actions/checkout@v4
104
194
195
+ - name : ' Install file generation Ruby dependencies'
196
+ run : bundle install
197
+
198
+ - name : ' Run file generation'
199
+ run : bash build.sh --dir ${{ env.IMAGE_DIR }} --version dev
200
+
105
201
- name : ' Set up QEMU'
106
202
uses : docker/setup-qemu-action@v3
107
203
@@ -116,28 +212,61 @@ jobs:
116
212
password : ${{ secrets.DOCKERHUB_TOKEN }}
117
213
118
214
# Docker image: madsciencelab-arm-none-eabi
119
- - name : ' Build Docker image ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}'
215
+ - name : ' Build Docker image ${{ env.IMAGE_NAME }}'
120
216
uses : docker/build-push-action@v6
121
217
with :
122
218
platforms : linux/amd64,linux/arm64
123
- file : build/${{ env.VARIANT }}/docker/Dockerfile
124
- build-args : CONTAINER_VERSION=${{ github.ref_name }}
125
- tags : ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}:latest
219
+ context : .
220
+ file : ${{ env.IMAGE_DIR }}/docker/Dockerfile
221
+ build-args : |
222
+ CONTAINER_VERSION=${{ github.ref_name }}
223
+ IMAGE_NAME=${{ env.IMAGE_NAME }}
224
+ tags : ${{ env.IMAGE_URL }}:latest
225
+ # Connect Docker driver to GitHub Action cache service
226
+ cache-from : type=gha
227
+ cache-to : type=gha,mode=max
228
+
229
+ # Zip generated files as a single artifact
230
+ - name : ' Archive ${{ env.IMAGE_NAME }} generated files as a single artifact'
231
+ run : zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome
232
+
233
+ # Upload the zip artifact
234
+ - uses : actions/upload-artifact@v4
235
+ with :
236
+ name : ${{ env.IMAGE_NAME }}
237
+ path : ${{ env.IMAGE_NAME }}.zip
238
+ if-no-files-found : error
126
239
127
240
madsciencelab-arm-none-eabi-plugins :
128
241
runs-on : ubuntu-latest
242
+ needs : [image-details]
129
243
permissions :
130
244
contents : read
131
245
packages : write
132
246
attestations : write
133
247
id-token : write
134
248
env :
135
- VARIANT : arm-none-eabi-plugins
249
+ IMAGE_NAME : ${{ needs.image-details.outputs.base-name }}-arm-none-eabi-plugins
250
+ IMAGE_URL : ${{ needs.image-details.outputs.base-url }}-arm-none-eabi-plugins
251
+ # Image variant name is drawn from final `--dir` entry in file generation command line
252
+ IMAGE_DIR : build/arm-none-eabi-plugins
136
253
137
254
steps :
255
+ - name : ' Set up Ruby for generation tool'
256
+ uses : ruby/setup-ruby@v1
257
+ with :
258
+ ruby-version : ' 3.3'
259
+ bundler-cache : true
260
+
138
261
- name : ' Checkout GitHub Action'
139
262
uses : actions/checkout@v4
140
263
264
+ - name : ' Install file generation Ruby dependencies'
265
+ run : bundle install
266
+
267
+ - name : ' Run file generation'
268
+ run : bash build.sh --dir build/arm-none-eabi --dir build/plugins --dir ${{ env.IMAGE_DIR }} --version dev
269
+
141
270
- name : ' Set up QEMU'
142
271
uses : docker/setup-qemu-action@v3
143
272
@@ -152,11 +281,68 @@ jobs:
152
281
password : ${{ secrets.DOCKERHUB_TOKEN }}
153
282
154
283
# Docker image: madsciencelab-arm-none-eabi-plugins
155
- - name : ' Build Docker image ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}'
284
+ - name : ' Build Docker image ${{ env.IMAGE_NAME }}'
156
285
uses : docker/build-push-action@v6
157
286
with :
158
287
platforms : linux/amd64,linux/arm64
159
- file : build/${{ env.VARIANT }}/docker/Dockerfile
160
- build-args : CONTAINER_VERSION=${{ github.ref_name }}
161
- tags : ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}:latest
288
+ context : .
289
+ file : ${{ env.IMAGE_DIR }}/docker/Dockerfile
290
+ build-args : |
291
+ CONTAINER_VERSION=${{ github.ref_name }}
292
+ IMAGE_NAME=${{ env.IMAGE_NAME }}
293
+ tags : ${{ env.IMAGE_URL }}:latest
294
+ # Connect Docker driver to GitHub Action cache service
295
+ cache-from : type=gha
296
+ cache-to : type=gha,mode=max
297
+
298
+ # Zip generated files as a single artifact
299
+ - name : ' Archive ${{ env.IMAGE_NAME }} generated files as a single artifact'
300
+ run : zip -j ${{ env.IMAGE_NAME }}.zip ${{ env.IMAGE_DIR }}/docker/Dockerfile ${{ env.IMAGE_DIR }}/assets/shell/welcome
162
301
302
+ # Upload the zip artifact
303
+ - uses : actions/upload-artifact@v4
304
+ with :
305
+ name : ${{ env.IMAGE_NAME }}
306
+ path : ${{ env.IMAGE_NAME }}.zip
307
+ if-no-files-found : error
308
+
309
+ # After all Docker image builds, collect results and publish a pre-release
310
+ artifacts-dev-build :
311
+ runs-on : ubuntu-latest
312
+ needs :
313
+ - madsciencelab
314
+ - madsciencelab-plugins
315
+ - madsciencelab-arm-none-eabi
316
+ - madsciencelab-arm-none-eabi-plugins
317
+ permissions :
318
+ contents : write
319
+
320
+ steps :
321
+ # Get the repo so we have info for generating release details
322
+ - name : ' Checkout GitHub Action'
323
+ uses : actions/checkout@v4
324
+
325
+ # Download all artifacts from the 4 Docker image builds
326
+ - uses : actions/download-artifact@v4
327
+ with :
328
+ # `pattern:` is a workaround to an artifact upload incompatibility with docker/build-push-action@v6
329
+ # Otherwise, apart from this bug requiring `pattern:` the default of all artifacts would occur without any intervention
330
+ # https://github.com/docker/build-push-action/issues/1167
331
+ pattern : " madsciencelab*"
332
+ path : artifacts
333
+
334
+ # Capture the SHA string
335
+ - name : ' Git commit short SHA as environment variable'
336
+ shell : bash
337
+ run : |
338
+ echo "SHA_SHORT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
339
+
340
+ - uses : ncipollo/release-action@v1
341
+ with :
342
+ prerelease : true
343
+ allowUpdates : true
344
+ bodyFile : .github/workflows/release.md
345
+ commit : ${{ github.sha }}
346
+ tag : ${{ env.SHA_SHORT }}
347
+ name : Dev Build ${{ env.SHA_SHORT }}
348
+ artifacts : " artifacts/*/*.zip"
0 commit comments