1515
1616# Based on https://docs.docker.com/build/ci/github-actions/multi-platform/
1717env :
18- REGISTRY_IMAGE : libfn/ci-build
18+ REGISTRY_IMAGE_BUILD : libfn/ci-build
19+ REGISTRY_IMAGE_PRE_COMMIT : libfn/ci-pre-commit
1920
2021jobs :
22+
2123 build :
2224 runs-on : ubuntu-latest
2325 strategy :
4547 id : meta
4648 uses : docker/metadata-action@v5
4749 with :
48- images : ${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}
49- tags : type=raw,value=${{ env.RELEASE }}
50+ images : ${{ env.REGISTRY_IMAGE_BUILD }}-${{ env.COMPILER }}
51+ tags : |
52+ type=raw,value=${{ env.RELEASE }}
53+ type=edge
5054
5155 - name : Set up QEMU
5256 uses : docker/setup-qemu-action@v3
@@ -68,10 +72,10 @@ jobs:
6872 build-args : |
6973 GCC_RELEASE=${{ env.RELEASE }}
7074 CLANG_RELEASE=${{ env.RELEASE }}
71- context : " {{defaultContext}}:ci/build"
72- file : Dockerfile.${{ env.COMPILER }}
75+ context : " {{defaultContext}}:ci/build/${{ env.COMPILER }}/ "
76+ file : Dockerfile
7377 labels : ${{ steps.meta.outputs.labels }}
74- outputs : type=image,name=${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }},push-by-digest=true,name-canonical=true,push=true
78+ outputs : type=image,name=${{ env.REGISTRY_IMAGE_BUILD }}-${{ env.COMPILER }},push-by-digest=true,name-canonical=true,push=true
7579 sbom : true
7680 provenance : mode=max
7781
@@ -84,12 +88,12 @@ jobs:
8488 - name : Upload digest
8589 uses : actions/upload-artifact@v4
8690 with :
87- name : digests-${{ env.COMPILER}}-${{ env.RELEASE }}-${{ env.PLATFORM_PAIR }}
91+ name : digests-build- ${{ env.COMPILER}}-${{ env.RELEASE }}-${{ env.PLATFORM_PAIR }}
8892 path : /tmp/digests/*
8993 if-no-files-found : error
9094 retention-days : 1
9195
92- merge :
96+ merge-build :
9397 runs-on : ubuntu-latest
9498 needs :
9599 - build
@@ -112,7 +116,111 @@ jobs:
112116 uses : actions/download-artifact@v4
113117 with :
114118 path : /tmp/digests
115- pattern : digests-${{ env.COMPILER}}-${{ env.RELEASE }}-*
119+ pattern : digests-build-${{ env.COMPILER}}-${{ env.RELEASE }}-*
120+ merge-multiple : true
121+
122+ - name : Set up Docker Buildx
123+ uses : docker/setup-buildx-action@v3
124+
125+ - name : Docker meta
126+ id : meta
127+ uses : docker/metadata-action@v5
128+ with :
129+ images : ${{ env.REGISTRY_IMAGE_BUILD }}-${{ env.COMPILER }}
130+ tags : |
131+ type=raw,value=${{ env.RELEASE }}
132+ type=edge
133+
134+ - name : Login to Docker Hub
135+ uses : docker/login-action@v3
136+ with :
137+ username : ${{ secrets.DOCKERHUB_USERNAME }}
138+ password : ${{ secrets.DOCKERHUB_TOKEN }}
139+
140+ - name : Create manifest list and push
141+ working-directory : /tmp/digests
142+ run : |
143+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
144+ $(printf '${{ env.REGISTRY_IMAGE_BUILD }}-${{ env.COMPILER }}@sha256:%s ' *)
145+
146+ - name : Inspect image
147+ run : |
148+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE_BUILD }}-${{ env.COMPILER }}:${{ steps.meta.outputs.version }}
149+
150+ pre-commit :
151+ runs-on : ubuntu-latest
152+ strategy :
153+ fail-fast : false
154+ matrix :
155+ platform :
156+ - linux/amd64
157+ - linux/arm64
158+
159+ steps :
160+ - name : Prepare
161+ run : |
162+ platform=${{ matrix.platform }}
163+ echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
164+
165+ - name : Docker meta
166+ id : meta
167+ uses : docker/metadata-action@v5
168+ with :
169+ images : ${{ env.REGISTRY_IMAGE_PRE_COMMIT }}
170+ tags : |
171+ type=schedule,pattern={{date 'YYYYMMDD'}}
172+ type=raw,value=latest,enable={{is_default_branch}}
173+ type=edge
174+
175+ - name : Set up QEMU
176+ uses : docker/setup-qemu-action@v3
177+
178+ - name : Set up Docker Buildx
179+ uses : docker/setup-buildx-action@v3
180+
181+ - name : Login to Docker Hub
182+ uses : docker/login-action@v3
183+ with :
184+ username : ${{ secrets.DOCKERHUB_USERNAME }}
185+ password : ${{ secrets.DOCKERHUB_TOKEN }}
186+
187+ - name : Build and push by digest
188+ id : build
189+ uses : docker/build-push-action@v6
190+ with :
191+ platforms : ${{ matrix.platform }}
192+ context : " {{defaultContext}}:ci/pre-commit/"
193+ file : Dockerfile
194+ labels : ${{ steps.meta.outputs.labels }}
195+ outputs : type=image,name=${{ env.REGISTRY_IMAGE_PRE_COMMIT }},push-by-digest=true,name-canonical=true,push=true
196+ sbom : true
197+ provenance : mode=max
198+
199+ - name : Export digest
200+ run : |
201+ mkdir -p /tmp/digests
202+ digest="${{ steps.build.outputs.digest }}"
203+ touch "/tmp/digests/${digest#sha256:}"
204+
205+ - name : Upload digest
206+ uses : actions/upload-artifact@v4
207+ with :
208+ name : digests-pre-commit-${{ env.PLATFORM_PAIR }}
209+ path : /tmp/digests/*
210+ if-no-files-found : error
211+ retention-days : 1
212+
213+ merge-pre-commit :
214+ runs-on : ubuntu-latest
215+ needs :
216+ - pre-commit
217+
218+ steps :
219+ - name : Download digests
220+ uses : actions/download-artifact@v4
221+ with :
222+ path : /tmp/digests
223+ pattern : digests-pre-commit-*
116224 merge-multiple : true
117225
118226 - name : Set up Docker Buildx
@@ -122,8 +230,11 @@ jobs:
122230 id : meta
123231 uses : docker/metadata-action@v5
124232 with :
125- images : ${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}
126- tags : type=raw,value=${{ env.RELEASE }}
233+ images : ${{ env.REGISTRY_IMAGE_PRE_COMMIT }}
234+ tags : |
235+ type=schedule,pattern={{date 'YYYYMMDD'}}
236+ type=raw,value=latest,enable={{is_default_branch}}
237+ type=edge
127238
128239 - name : Login to Docker Hub
129240 uses : docker/login-action@v3
@@ -135,8 +246,8 @@ jobs:
135246 working-directory : /tmp/digests
136247 run : |
137248 docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
138- $(printf '${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}@sha256:%s ' *)
249+ $(printf '${{ env.REGISTRY_IMAGE_PRE_COMMIT }}@sha256:%s ' *)
139250
140251 - name : Inspect image
141252 run : |
142- docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}-${{ env.COMPILER }}:${{ steps.meta.outputs.version }}
253+ docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE_PRE_COMMIT }}:${{ steps.meta.outputs.version }}
0 commit comments