Skip to content

Commit 1cf36a1

Browse files
authored
ci: use split native builds for images (#468)
Fixes #74 Signed-off-by: Aurora Gaffney <[email protected]>
1 parent 8611570 commit 1cf36a1

File tree

2 files changed

+68
-10
lines changed

2 files changed

+68
-10
lines changed

.github/workflows/ci-docker.yml

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ permissions:
1313

1414
jobs:
1515
docker:
16-
runs-on: ubuntu-latest
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
include:
20+
- os: ubuntu-latest
21+
arch: amd64
22+
runs-on: ${{ matrix.os }}
1723
steps:
1824
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout/releases/tag/v5.0.0
1925
with:
2026
fetch-depth: '0'
21-
- name: qemu
22-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 https://github.com/docker/setup-qemu-action/releases/tag/v3.6.0
2327
- uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 https://github.com/docker/setup-buildx-action/releases/tag/v3.11.1
2428
- id: meta
2529
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 https://github.com/docker/metadata-action/releases/tag/v5.8.0
@@ -30,7 +34,6 @@ jobs:
3034
with:
3135
context: .
3236
push: false
33-
### TODO: test multiple platforms
34-
# platforms: linux/amd64,linux/arm64
37+
platforms: linux/${{ matrix.arch }}
3538
tags: ${{ steps.meta.outputs.tags }}
3639
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/publish.yml

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,6 @@ jobs:
253253
subject-path: '${{ env.APPLICATION_NAME }}'
254254

255255
build-images:
256-
runs-on: ubuntu-latest
257256
needs: [create-draft-release]
258257
permissions:
259258
actions: write
@@ -263,13 +262,20 @@ jobs:
263262
id-token: write
264263
packages: write
265264
statuses: write
265+
strategy:
266+
fail-fast: false
267+
matrix:
268+
include:
269+
- os: ubuntu-latest
270+
arch: amd64
271+
- os: ubuntu-24.04-arm
272+
arch: arm64
273+
runs-on: ${{ matrix.os }}
266274
steps:
267275
- run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV"
268276
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout/releases/tag/v5.0.0
269277
with:
270278
fetch-depth: '0'
271-
- name: Set up QEMU
272-
uses: docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0 https://github.com/docker/setup-qemu-action/releases/tag/v3.6.0
273279
- name: Set up Docker Buildx
274280
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3.11.1 https://github.com/docker/setup-buildx-action/releases/tag/v3.11.1
275281
- name: Login to Docker Hub
@@ -289,6 +295,9 @@ jobs:
289295
images: |
290296
blinklabs/adder
291297
ghcr.io/${{ github.repository }}
298+
flavor: |
299+
latest=false
300+
suffix=-${{ matrix.arch }}
292301
tags: |
293302
# Only version, no revision
294303
type=match,pattern=v(.*)-(.*),group=1
@@ -301,7 +310,7 @@ jobs:
301310
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0 https://github.com/docker/build-push-action/releases/tag/v6.18.0
302311
with:
303312
outputs: "type=registry,push=true"
304-
platforms: linux/amd64,linux/arm64
313+
platforms: linux/${{ matrix.arch }}
305314
tags: ${{ steps.meta.outputs.tags }}
306315
labels: ${{ steps.meta.outputs.labels }}
307316
- name: Attest Docker Hub image
@@ -316,6 +325,52 @@ jobs:
316325
subject-name: ghcr.io/${{ github.repository }}
317326
subject-digest: ${{ steps.push.outputs.digest }}
318327
push-to-registry: true
328+
329+
build-image-manifest:
330+
needs: [build-images]
331+
permissions:
332+
contents: read
333+
packages: write
334+
runs-on: ubuntu-latest
335+
steps:
336+
- name: Login to Docker Hub
337+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 https://github.com/docker/login-action/releases/tag/v3.5.0
338+
with:
339+
username: blinklabs
340+
password: ${{ secrets.DOCKER_PASSWORD }} # uses token
341+
- name: Login to GHCR
342+
uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0 https://github.com/docker/login-action/releases/tag/v3.5.0
343+
with:
344+
username: ${{ github.repository_owner }}
345+
password: ${{ secrets.GITHUB_TOKEN }}
346+
registry: ghcr.io
347+
- id: meta
348+
uses: docker/metadata-action@c1e51972afc2121e065aed6d45c65596fe445f3f # v5.8.0 https://github.com/docker/metadata-action/releases/tag/v5.8.0
349+
with:
350+
images: |
351+
blinklabs/adder
352+
ghcr.io/${{ github.repository }}
353+
flavor: |
354+
latest=false
355+
tags: |
356+
# Only version, no revision
357+
type=match,pattern=v(.*)-(.*),group=1
358+
# branch
359+
type=ref,event=branch
360+
# semver
361+
type=semver,pattern={{version}}
362+
- name: manifest-create
363+
shell: bash
364+
run: |
365+
for t in `echo '${{ steps.meta.outputs.tags }}'`; do
366+
# Extract the underlying manifests from each manifests list and create a new single manifest list
367+
docker manifest create ${t} \
368+
$(docker manifest inspect ${t}-amd64 | jq -r '.manifests[] | .digest' | sed -e "s|^|${t%:*}@|") \
369+
$(docker manifest inspect ${t}-arm64 | jq -r '.manifests[] | .digest' | sed -e "s|^|${t%:*}@|")
370+
docker manifest push ${t}
371+
done
372+
# Checkout repo so README.md is available for next step
373+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 https://github.com/actions/checkout/releases/tag/v5.0.0
319374
# Update Docker Hub from README
320375
- name: Docker Hub Description
321376
uses: peter-evans/dockerhub-description@432a30c9e07499fd01da9f8a49f0faf9e0ca5b77 # v4.0.2 https://github.com/peter-evans/dockerhub-description/releases/tag/v4.0.2
@@ -330,7 +385,7 @@ jobs:
330385
runs-on: ubuntu-latest
331386
permissions:
332387
contents: write
333-
needs: [create-draft-release, build-binaries, build-images]
388+
needs: [create-draft-release, build-binaries, build-images, build-image-manifest]
334389
steps:
335390
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 https://github.com/actions/github-script/releases/tag/v7.0.1
336391
if: startsWith(github.ref, 'refs/tags/')

0 commit comments

Comments
 (0)