@@ -18,8 +18,17 @@ permissions:
1818 attestations : write
1919
2020jobs :
21- build-and-push :
22- runs-on : ubuntu-24.04
21+ build :
22+ # Multiplatform builds: https://docs.docker.com/build/ci/github-actions/multi-platform/#distribute-build-across-multiple-runners
23+ strategy :
24+ fail-fast : false
25+ matrix :
26+ include :
27+ - platform : linux/amd64
28+ runner : ubuntu-24.04
29+ - platform : linux/arm64
30+ runner : ubuntu-24.04-arm
31+ runs-on : ${{ matrix.runner }}
2332 timeout-minutes : 30
2433
2534 steps :
2938 - name : Set build metadata
3039 id : meta
3140 run : |
41+ platform=${{ matrix.platform }}
42+ echo "platform_pair=${platform//\//-}" >> $GITHUB_OUTPUT
3243 echo "git_commit_hash_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
3344 echo "source_date_epoch=$(git log -1 --format=%ct)" >> $GITHUB_OUTPUT
3445
5768 SOURCE_DATE_EPOCH=${{ steps.meta.outputs.source_date_epoch }}
5869 tags : ${{ steps.docker_meta.outputs.tags }}
5970 labels : ${{ steps.docker_meta.outputs.labels }}
60- platforms : linux/amd64
61- cache-from : type=gha
62- cache-to : type=gha,mode=max
71+ platforms : ${{ matrix.platform }}
72+ cache-from : type=gha,scope=${{ steps.meta.outputs.platform_pair }}
73+ cache-to : type=gha,mode=max,scope=${{ steps.meta.outputs.platform_pair }}
6374
6475 - name : Validate image
6576 run : |
7485
7586 # According to docs this operation should rely on caching from previous step so no duplicate build should happen.
7687 # See: https://docs.docker.com/build/ci/github-actions/test-before-push/
77- - name : Publish image
88+ - name : Push image by digest
7889 id : push
7990 uses : docker/build-push-action@v6
8091 with :
@@ -83,15 +94,69 @@ jobs:
8394 build-args : |
8495 GIT_COMMIT_HASH_SHORT=${{ steps.meta.outputs.git_commit_hash_short }}
8596 SOURCE_DATE_EPOCH=${{ steps.meta.outputs.source_date_epoch }}
86- tags : ${{ steps.docker_meta.outputs.tags }}
8797 labels : ${{ steps.docker_meta.outputs.labels }}
88- platforms : linux/amd64
89- cache-from : type=gha
90- cache-to : type=gha,mode=max
98+ platforms : ${{ matrix.platform }}
99+ cache-from : type=gha,scope=${{ steps.meta.outputs.platform_pair }}
100+ cache-to : type=gha,mode=max,scope=${{ steps.meta.outputs.platform_pair }}
101+ outputs : type=image,name=nethermindeth/pluto,push-by-digest=true,name-canonical=true
102+
103+ - name : Export digest
104+ run : |
105+ mkdir -p ${{ runner.temp }}/digests
106+ digest="${{ steps.push.outputs.digest }}"
107+ touch "${{ runner.temp }}/digests/${digest#sha256:}"
108+
109+ - name : Upload digest
110+ uses : actions/upload-artifact@v4
111+ with :
112+ name : digests-${{ steps.meta.outputs.platform_pair }}
113+ path : ${{ runner.temp }}/digests/*
114+ if-no-files-found : error
115+ retention-days : 1
91116
92117 - name : Generate attestations
93118 uses : actions/attest-build-provenance@v3
94119 with :
95120 subject-name : docker.io/nethermindeth/pluto
96121 subject-digest : ${{ steps.push.outputs.digest }}
97122 push-to-registry : true
123+
124+ merge :
125+ runs-on : ubuntu-24.04
126+ timeout-minutes : 5
127+ needs : build
128+ if : ${{ needs.build.result == 'success' }}
129+
130+ steps :
131+ - name : Download digests
132+ uses : actions/download-artifact@v4
133+ with :
134+ path : ${{ runner.temp }}/digests
135+ pattern : digests-*
136+ merge-multiple : true
137+
138+ - name : Docker metadata
139+ id : docker_meta
140+ uses : docker/metadata-action@v5
141+ with :
142+ images : nethermindeth/pluto
143+
144+ - name : Set up Docker Buildx
145+ uses : docker/setup-buildx-action@v3
146+
147+ - name : Login to Docker Hub
148+ uses : docker/login-action@v3
149+ with :
150+ username : ${{ secrets.DOCKER_HUB_USERNAME }}
151+ password : ${{ secrets.DOCKER_HUB_PASSWORD }}
152+
153+ - name : Create manifest list and push
154+ working-directory : ${{ runner.temp }}/digests
155+ run : |
156+ docker buildx imagetools create \
157+ $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
158+ $(printf 'nethermindeth/pluto@sha256:%s ' *)
159+
160+ - name : Inspect image
161+ run : |
162+ docker buildx imagetools inspect nethermindeth/pluto:${{ steps.docker_meta.outputs.version }}
0 commit comments