44 workflow_dispatch :
55 push :
66 branches :
7- - ' * '
7+ - " ** "
88 pull_request :
99 branches :
10- - ' main'
10+ - " main"
1111
1212env :
13- IMAGE_BASE_NAME : ' throwtheswitch/madsciencelab'
13+ IMAGE_ORG : ' throwtheswitch'
14+ IMAGE_BASE_NAME : ' madsciencelab'
1415
1516
1617jobs :
1718 # Jobs organized for concurrent Docker image builds
1819 # Jobs only build :latest images without pushing to Docker Hub
1920
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+
2031 madsciencelab :
2132 runs-on : ubuntu-latest
33+ needs : [image-details]
2234 permissions :
2335 contents : read
2436 packages : write
2537 attestations : write
2638 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
2744
2845 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+
2952 - name : ' Checkout GitHub Action'
3053 uses : actions/checkout@v4
3154
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+
3262 - name : ' Set up QEMU'
3363 uses : docker/setup-qemu-action@v3
3464
@@ -44,28 +74,61 @@ jobs:
4474
4575 # Docker image: madsciencelab
4676 # 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 }}'
4878 uses : docker/build-push-action@v6
4979 with :
5080 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
54101
55102 madsciencelab-plugins :
56103 runs-on : ubuntu-latest
104+ needs : [image-details]
57105 permissions :
58106 contents : read
59107 packages : write
60108 attestations : write
61109 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
64115
65116 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+
66123 - name : ' Checkout GitHub Action'
67124 uses : actions/checkout@v4
68125
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+
69132 - name : ' Set up QEMU'
70133 uses : docker/setup-qemu-action@v3
71134
@@ -80,28 +143,61 @@ jobs:
80143 password : ${{ secrets.DOCKERHUB_TOKEN }}
81144
82145 # Docker image: madsciencelab-plugins
83- - name : ' Build Docker image ${{ env.IMAGE_BASE_NAME }}-${{ env.VARIANT }}'
146+ - name : ' Build Docker image ${{ env.IMAGE_NAME }}'
84147 uses : docker/build-push-action@v6
85148 with :
86149 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
90170
91171 madsciencelab-arm-none-eabi :
92172 runs-on : ubuntu-latest
173+ needs : [image-details]
93174 permissions :
94175 contents : read
95176 packages : write
96177 attestations : write
97178 id-token : write
98179 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
100184
101185 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+
102192 - name : ' Checkout GitHub Action'
103193 uses : actions/checkout@v4
104194
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+
105201 - name : ' Set up QEMU'
106202 uses : docker/setup-qemu-action@v3
107203
@@ -116,28 +212,61 @@ jobs:
116212 password : ${{ secrets.DOCKERHUB_TOKEN }}
117213
118214 # 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 }}'
120216 uses : docker/build-push-action@v6
121217 with :
122218 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
126239
127240 madsciencelab-arm-none-eabi-plugins :
128241 runs-on : ubuntu-latest
242+ needs : [image-details]
129243 permissions :
130244 contents : read
131245 packages : write
132246 attestations : write
133247 id-token : write
134248 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
136253
137254 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+
138261 - name : ' Checkout GitHub Action'
139262 uses : actions/checkout@v4
140263
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+
141270 - name : ' Set up QEMU'
142271 uses : docker/setup-qemu-action@v3
143272
@@ -152,11 +281,68 @@ jobs:
152281 password : ${{ secrets.DOCKERHUB_TOKEN }}
153282
154283 # 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 }}'
156285 uses : docker/build-push-action@v6
157286 with :
158287 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
162301
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