1717
1818jobs :
1919 # Build the Docker image for Debian using different versions of GCC and Clang.
20+ # Note, the `os` part of matrix must be kept in sync with the `merge` job below
2021 build :
2122 strategy :
2223 matrix :
5657 steps :
5758 - name : Checkout repository
5859 uses : actions/checkout@v4
59- - name : Set up QEMU
60- uses : docker/setup-qemu-action@v3
6160 - name : Set up Docker Buildx
6261 uses : docker/setup-buildx-action@v3
6362 - name : Login to GitHub Registry
6665 registry : ${{ env.CONTAINER_REGISTRY }}
6766 username : ${{ github.repository_owner }}
6867 password : ${{ secrets.GITHUB_TOKEN }}
69- - name : Determine the Docker image name.
68+ - name : Prepare environment
7069 run : |
7170 # Convert the repository name to lowercase as the organization name is
7271 # uppercase, which is not permitted by the Docker registry. It's 2025 and GitHub
7574 CONTAINER_REPO=${GITHUB_REPO@L}
7675 echo "CONTAINER_REPOSITORY=${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
7776 echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
77+ PLATFORM=${{ matrix.architecture.platform }}
78+ echo "PLATFORM_PAIR=${PLATFORM//\//-}" >> $GITHUB_ENV
7879 - name : Prepare container metadata
7980 id : meta
8081 uses : docker/metadata-action@v5
8990 org.opencontainers.image.vendor=XRPLF
9091 org.opencontainers.image.title=${{ env.CONTAINER_REPOSITORY }}
9192 - name : Build and push the Docker image
93+ id : build
9294 uses : docker/build-push-action@v6
9395 with :
9496 build-args : |
@@ -104,7 +106,97 @@ jobs:
104106 outputs : type=image,name=${{ env.CONTAINER_IMAGE }},push-by-digest=true,name-canonical=true,push=true
105107 platforms : ${{ matrix.architecture.platform }}
106108 provenance : mode=max
107- push : ${{ github.event_name != 'pull_request ' }}
109+ push : ${{ github.ref_type == 'branch' && github.ref_name == 'main ' }}
108110 sbom : true
109111 labels : ${{ steps.meta.outputs.labels }}
110112 target : ${{ matrix.os.compiler_name }}
113+ - name : Export digest
114+ if : ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
115+ shell : bash
116+ run : |
117+ mkdir -p /tmp/digests
118+ DIGEST="${{ steps.build.outputs.digest }}"
119+ touch "/tmp/digests/${DIGEST#sha256:}"
120+ - name : Upload digest
121+ if : ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
122+ uses : actions/upload-artifact@v4
123+ with :
124+ name : digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-${{ env.PLATFORM_PAIR }}
125+ path : /tmp/digests/*
126+ if-no-files-found : error
127+ retention-days : 1
128+
129+ merge :
130+ if : ${{ github.ref_type == 'branch' && github.ref_name == 'main' }}
131+ strategy :
132+ matrix :
133+ os :
134+ - release : bookworm
135+ compiler_name : gcc
136+ compiler_version : 12
137+ - release : bookworm
138+ compiler_name : gcc
139+ compiler_version : 13
140+ - release : bookworm
141+ compiler_name : gcc
142+ compiler_version : 14
143+ - release : bookworm
144+ compiler_name : clang
145+ compiler_version : 16
146+ - release : bookworm
147+ compiler_name : clang
148+ compiler_version : 17
149+ - release : bookworm
150+ compiler_name : clang
151+ compiler_version : 18
152+ - release : bookworm
153+ compiler_name : clang
154+ compiler_version : 19
155+ - release : bookworm
156+ compiler_name : clang
157+ compiler_version : 20
158+ runs-on : ubuntu-24.04
159+ needs :
160+ - build
161+ permissions :
162+ packages : write
163+ steps :
164+ - name : Checkout repository
165+ uses : actions/checkout@v4
166+ - name : Download digests
167+ uses : actions/download-artifact@v4
168+ with :
169+ path : /tmp/digests
170+ pattern : digests-${{ matrix.os.release }}-${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-*
171+ merge-multiple : true
172+ - name : Set up Docker Buildx
173+ uses : docker/setup-buildx-action@v3
174+ - name : Login to GitHub Registry
175+ uses : docker/login-action@v3
176+ with :
177+ registry : ${{ env.CONTAINER_REGISTRY }}
178+ username : ${{ github.repository_owner }}
179+ password : ${{ secrets.GITHUB_TOKEN }}
180+ - name : Prepare environment
181+ run : |
182+ GITHUB_REPO=${{ github.repository }}
183+ CONTAINER_REPO=${GITHUB_REPO@L}
184+ echo "CONTAINER_IMAGE=${CONTAINER_REGISTRY}/${CONTAINER_REPO}/debian-${{ matrix.os.release }}" >> $GITHUB_ENV
185+ - name : Prepare container metadata
186+ id : meta
187+ uses : docker/metadata-action@v5
188+ with :
189+ images : ${{ env.CONTAINER_IMAGE }}
190+ tags : |
191+ type=raw,value=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}
192+ type=sha,prefix=${{ matrix.os.compiler_name }}-${{ matrix.os.compiler_version }}-sha-
193+ - name : Create manifest list and push
194+ working-directory : /tmp/digests
195+ shell : bash
196+ run : |
197+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
198+ $(printf '${{ env.CONTAINER_IMAGE }}@sha256:%s ' *)
199+ - name : Inspect image
200+ shell : bash
201+ run : |
202+ docker buildx imagetools inspect ${{ env.CONTAINER_IMAGE }}:${{ steps.meta.outputs.version }}
0 commit comments