Skip to content

Commit 0a8eedb

Browse files
committed
ci: push multi-arch ubuntu images using docker manifest
1 parent 380714f commit 0a8eedb

File tree

1 file changed

+79
-4
lines changed

1 file changed

+79
-4
lines changed

.github/workflows/CI.yml

Lines changed: 79 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,11 @@ jobs:
253253
with:
254254
name: dist
255255

256+
- name: Define Platform Suffix
257+
id: platform
258+
run: |
259+
echo "suffix=${{ matrix.platform == 'linux/amd64' && 'linux-amd64' || 'linux-arm64' }}" >> $GITHUB_OUTPUT
260+
256261
- name: Set up Docker Buildx
257262
uses: docker/setup-buildx-action@v3
258263

@@ -270,10 +275,17 @@ jobs:
270275
file: ./dev/docker/ci/${{ matrix.container.distro }}.dockerfile
271276
push: ${{ github.event_name != 'pull_request' }}
272277
platforms: ${{ matrix.platform }}
273-
tags: aminya/${{ matrix.container.image }}:${{ matrix.container.tag }},aminya/${{ matrix.container.image }}:latest
278+
tags: aminya/${{ matrix.container.image }}:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }}
274279
cache-from: type=registry,ref=aminya/${{ matrix.container.image }}:latest
275280
cache-to: type=inline
276281

282+
- name: Tag latest locally
283+
run: docker tag aminya/${{ matrix.container.image }}:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}:latest
284+
285+
- name: Push latest to Docker Hub
286+
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
287+
run: docker push aminya/${{ matrix.container.image }}:latest
288+
277289
- name: Docker Readme for setup-cpp-${{matrix.container.distro }}
278290
if: ${{ github.event_name != 'pull_request' }}
279291
uses: peter-evans/dockerhub-description@v4
@@ -290,10 +302,17 @@ jobs:
290302
file: ./dev/docker/ci/${{ matrix.container.distro }}-llvm.dockerfile
291303
push: ${{ github.event_name != 'pull_request' }}
292304
platforms: ${{ matrix.platform }}
293-
tags: aminya/${{ matrix.container.image }}-llvm:${{ matrix.container.tag }},aminya/${{ matrix.container.image }}-llvm:latest
305+
tags: aminya/${{ matrix.container.image }}-llvm:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }}
294306
cache-from: type=registry,ref=aminya/${{ matrix.container.image }}-llvm:latest
295307
cache-to: type=inline
296308

309+
- name: Tag latest locally
310+
run: docker tag aminya/${{ matrix.container.image }}-llvm:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-llvm:latest
311+
312+
- name: Push latest to Docker Hub
313+
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
314+
run: docker push aminya/${{ matrix.container.image }}-llvm:latest
315+
297316
- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-llvm
298317
if: ${{ github.event_name != 'pull_request' }}
299318
uses: peter-evans/dockerhub-description@v4
@@ -320,10 +339,17 @@ jobs:
320339
file: ./dev/docker/ci/${{ matrix.container.distro }}-gcc.dockerfile
321340
push: ${{ github.event_name != 'pull_request' }}
322341
platforms: ${{ matrix.platform }}
323-
tags: aminya/${{ matrix.container.image }}-gcc:${{ matrix.container.tag }},aminya/${{ matrix.container.image }}-gcc:latest
342+
tags: aminya/${{ matrix.container.image }}-gcc:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }}
324343
cache-from: type=registry,ref=aminya/${{ matrix.container.image }}-gcc:latest
325344
cache-to: type=inline
326345

346+
- name: Tag latest locally
347+
run: docker tag aminya/${{ matrix.container.image }}-gcc:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-gcc:latest
348+
349+
- name: Push latest to Docker Hub
350+
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
351+
run: docker push aminya/${{ matrix.container.image }}-gcc:latest
352+
327353
- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-gcc
328354
if: ${{ github.event_name != 'pull_request' }}
329355
uses: peter-evans/dockerhub-description@v4
@@ -351,10 +377,17 @@ jobs:
351377
file: ./dev/docker/ci/${{ matrix.container.distro }}-mingw.dockerfile
352378
push: ${{ github.event_name != 'pull_request' }}
353379
platforms: ${{ matrix.platform }}
354-
tags: aminya/${{ matrix.container.image }}-mingw:${{ matrix.container.tag }},aminya/${{ matrix.container.image }}-mingw:latest
380+
tags: aminya/${{ matrix.container.image }}-mingw:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }}
355381
cache-from: type=registry,ref=aminya/${{ matrix.container.image }}-mingw:latest
356382
cache-to: type=inline
357383

384+
- name: Tag latest locally
385+
run: docker tag aminya/${{ matrix.container.image }}-mingw:${{ matrix.container.tag }}-${{ steps.platform.outputs.suffix }} aminya/${{ matrix.container.image }}-mingw:latest
386+
387+
- name: Push latest to Docker Hub
388+
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'ubuntu' }}
389+
run: docker push aminya/${{ matrix.container.image }}-mingw:latest
390+
358391
- name: Docker Readme for setup-cpp-${{matrix.container.distro }}-mingw
359392
if: ${{ github.event_name != 'pull_request' && matrix.container.distro != 'fedora' }}
360393
uses: peter-evans/dockerhub-description@v4
@@ -374,6 +407,48 @@ jobs:
374407
platforms: ${{ matrix.platform }}
375408
tags: aminya/test-${{ matrix.container.image }}-mingw:${{ matrix.container.tag }}
376409

410+
Docker-Manifest:
411+
needs: [Docker]
412+
runs-on: ubuntu-24.04
413+
if: ${{ github.event_name != 'pull_request' }}
414+
steps:
415+
- name: Set up Docker Buildx
416+
uses: docker/setup-buildx-action@v3
417+
418+
- name: Login to Docker Hub
419+
uses: docker/login-action@v3
420+
with:
421+
username: aminya
422+
password: ${{ secrets.DOCKERHUB_TOKEN }}
423+
424+
- name: Enable experimental features
425+
run: |
426+
mkdir -p ~/.docker
427+
echo '{"experimental": "enabled"}' > ~/.docker/config.json
428+
429+
- name: Create and push multi-arch manifests
430+
run: |
431+
TAG="22.04-1.1.1"
432+
DISTRO="ubuntu"
433+
434+
# Create and push manifests for each variant
435+
VARIANTS=("" "-llvm" "-gcc" "-mingw")
436+
for VARIANT in "${VARIANTS[@]}"; do
437+
echo "Creating manifest for setup-cpp-$DISTRO$VARIANT"
438+
439+
# Create versioned manifest
440+
docker manifest create "aminya/setup-cpp-$DISTRO$VARIANT:$TAG" \
441+
"aminya/setup-cpp-$DISTRO$VARIANT:$TAG-linux-amd64" \
442+
"aminya/setup-cpp-$DISTRO$VARIANT:$TAG-linux-arm64"
443+
docker manifest push "aminya/setup-cpp-$DISTRO$VARIANT:$TAG"
444+
445+
# Create latest manifest
446+
docker manifest create "aminya/setup-cpp-$DISTRO$VARIANT:latest" \
447+
"aminya/setup-cpp-$DISTRO$VARIANT:$TAG-linux-amd64" \
448+
"aminya/setup-cpp-$DISTRO$VARIANT:$TAG-linux-arm64"
449+
docker manifest push "aminya/setup-cpp-$DISTRO$VARIANT:latest"
450+
done
451+
377452
Release:
378453
if: startsWith(github.ref, 'refs/tags/')
379454
needs: [Build, BuildExecutable, Test]

0 commit comments

Comments
 (0)