Skip to content

Commit 2442526

Browse files
authored
fix(release): speed up container image builds (#41)
1 parent 4e62ed2 commit 2442526

1 file changed

Lines changed: 33 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,12 @@ jobs:
223223
gh release edit "${edit_args[@]}"
224224
225225
container-build:
226-
name: Build container images (${{ matrix.arch }})
226+
name: Build container images (${{ matrix.arch }}, ${{ matrix.family }})
227227
needs: publish
228228
runs-on: ${{ matrix.runner }}
229+
concurrency:
230+
group: release-container-cache-${{ matrix.arch }}-${{ matrix.family }}
231+
cancel-in-progress: false
229232
permissions:
230233
contents: read
231234
packages: write
@@ -236,9 +239,19 @@ jobs:
236239
- arch: amd64
237240
platform: linux/amd64
238241
runner: ubuntu-24.04
242+
family: gnu
243+
- arch: amd64
244+
platform: linux/amd64
245+
runner: ubuntu-24.04
246+
family: musl
247+
- arch: arm64
248+
platform: linux/arm64
249+
runner: ubuntu-24.04-arm
250+
family: gnu
239251
- arch: arm64
240252
platform: linux/arm64
241253
runner: ubuntu-24.04-arm
254+
family: musl
242255
env:
243256
IMAGE: ghcr.io/${{ github.repository }}
244257
steps:
@@ -257,6 +270,7 @@ jobs:
257270
username: ${{ github.actor }}
258271
password: ${{ secrets.GITHUB_TOKEN }}
259272
- name: Build and push slim image by digest
273+
if: matrix.family == 'gnu'
260274
id: slim
261275
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
262276
with:
@@ -266,8 +280,10 @@ jobs:
266280
build-args: |
267281
VERSION=${{ steps.version.outputs.version }}
268282
REVISION=${{ github.sha }}
283+
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.arch }}-${{ matrix.family }}
269284
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
270285
- name: Build and push Bookworm image by digest
286+
if: matrix.family == 'gnu'
271287
id: bookworm
272288
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
273289
with:
@@ -277,8 +293,11 @@ jobs:
277293
build-args: |
278294
VERSION=${{ steps.version.outputs.version }}
279295
REVISION=${{ github.sha }}
296+
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.arch }}-${{ matrix.family }}
297+
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.arch }}-${{ matrix.family }},mode=max,ignore-error=true
280298
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
281299
- name: Build and push Alpine image by digest
300+
if: matrix.family == 'musl'
282301
id: alpine
283302
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
284303
with:
@@ -288,22 +307,31 @@ jobs:
288307
build-args: |
289308
VERSION=${{ steps.version.outputs.version }}
290309
REVISION=${{ github.sha }}
310+
cache-from: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.arch }}-${{ matrix.family }}
311+
cache-to: type=registry,ref=${{ env.IMAGE }}:buildcache-${{ matrix.arch }}-${{ matrix.family }},mode=max,ignore-error=true
291312
outputs: type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
292-
- name: Export image digests
313+
- name: Export GNU image digests
314+
if: matrix.family == 'gnu'
293315
env:
294316
SLIM_DIGEST: ${{ steps.slim.outputs.digest }}
295317
BOOKWORM_DIGEST: ${{ steps.bookworm.outputs.digest }}
296-
ALPINE_DIGEST: ${{ steps.alpine.outputs.digest }}
297318
shell: bash
298319
run: |
299-
mkdir -p /tmp/digests/{slim,bookworm,alpine}
320+
mkdir -p /tmp/digests/{slim,bookworm}
300321
touch "/tmp/digests/slim/${SLIM_DIGEST#sha256:}"
301322
touch "/tmp/digests/bookworm/${BOOKWORM_DIGEST#sha256:}"
323+
- name: Export Alpine image digest
324+
if: matrix.family == 'musl'
325+
env:
326+
ALPINE_DIGEST: ${{ steps.alpine.outputs.digest }}
327+
shell: bash
328+
run: |
329+
mkdir -p /tmp/digests/alpine
302330
touch "/tmp/digests/alpine/${ALPINE_DIGEST#sha256:}"
303331
- name: Upload image digests
304332
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
305333
with:
306-
name: container-digests-${{ matrix.arch }}
334+
name: container-digests-${{ matrix.arch }}-${{ matrix.family }}
307335
path: /tmp/digests
308336
if-no-files-found: error
309337
retention-days: 1

0 commit comments

Comments
 (0)