1414 REGISTRY : ghcr.io
1515jobs :
1616 build-images :
17- name : ${{ matrix.variance.name }}
18- runs-on : ubuntu-latest
17+ name : Build ${{ matrix.variance.name }} (${{ matrix.platform.arch }})
18+ runs-on : ${{ matrix.platform.runner }}
1919 permissions :
2020 contents : read
2121 packages : write
22- attestations : write
23- id-token : write
2422 strategy :
2523 fail-fast : false
2624 matrix :
25+ platform :
26+ - runner : ubuntu-latest
27+ arch : amd64
28+ - runner : ubuntu-24.04-arm
29+ arch : arm64
2730 variance :
2831 - name : Ubuntu-22.04/CUDA-11.8.0
29- image : " ${{ github.repository }} -ubuntu22-cuda11"
32+ image : " rust-gpu/rust-cuda -ubuntu22-cuda11"
3033 dockerfile : ./container/ubuntu22-cuda11/Dockerfile
3134 - name : Ubuntu-22.04/CUDA-12.8.1
32- image : " ${{ github.repository }} -ubuntu22-cuda12"
35+ image : " rust-gpu/rust-cuda -ubuntu22-cuda12"
3336 dockerfile : ./container/ubuntu22-cuda12/Dockerfile
3437 - name : Ubuntu-24.04/CUDA-12.8.1
35- image : " ${{ github.repository }} -ubuntu24-cuda12"
38+ image : " rust-gpu/rust-cuda -ubuntu24-cuda12"
3639 dockerfile : ./container/ubuntu24-cuda12/Dockerfile
3740 - name : RockyLinux-9/CUDA-12.8.1
38- image : " ${{ github.repository }} -rockylinux9-cuda12"
41+ image : " rust-gpu/rust-cuda -rockylinux9-cuda12"
3942 dockerfile : ./container/rockylinux9-cuda12/Dockerfile
4043 steps :
4144 - name : Checkout repository
4245 uses : actions/checkout@v4
46+ - name : Validate platform
47+ run : |
48+ ARCH=$(uname -m)
49+ if [[ "${{ matrix.platform.arch }}" == "amd64" && "$ARCH" != "x86_64" ]]; then
50+ echo "Error: Expected x86_64 but got $ARCH"
51+ exit 1
52+ fi
53+ if [[ "${{ matrix.platform.arch }}" == "arm64" && "$ARCH" != "aarch64" ]]; then
54+ echo "Error: Expected aarch64 but got $ARCH"
55+ exit 1
56+ fi
57+ echo "Platform validation passed: $ARCH matches ${{ matrix.platform.arch }}"
4358 - name : Log in to the Container registry
4459 uses : docker/login-action@v3
4560 with :
@@ -51,24 +66,85 @@ jobs:
5166 uses : docker/metadata-action@v5
5267 with :
5368 images : ${{ env.REGISTRY }}/${{ matrix.variance.image }}
54- tags : |
55- type=ref,event=branch
56- type=sha,format=short
57- type=raw,value=latest
5869 - name : Set up Docker Buildx
5970 uses : docker/setup-buildx-action@v3
60- - name : Build and push container images
61- id : push
71+ - name : Build and push by digest
72+ id : build
6273 uses : docker/build-push-action@v6
6374 with :
6475 context : .
6576 file : ${{ matrix.variance.dockerfile }}
66- tags : ${{ steps.meta.outputs.tags }}
77+ platforms : linux/ ${{ matrix.platform.arch }}
6778 labels : ${{ steps.meta.outputs.labels }}
68- push : ${{ github.event_name != 'pull_request' }}
69- - name : Generate artifact attestation
70- uses : actions/attest-build-provenance@v2
79+ outputs : type=image,name=${{ env.REGISTRY }}/${{ matrix.variance.image }},push-by-digest=true,name-canonical=true,push=${{ github.event_name != 'pull_request' }}
80+ cache-from : type=gha
81+ cache-to : type=gha,mode=max
82+ - name : Export digest
83+ if : github.event_name != 'pull_request'
84+ run : |
85+ mkdir -p /tmp/digests
86+ digest="${{ steps.build.outputs.digest }}"
87+ touch "/tmp/digests/${digest#sha256:}"
88+ - name : Upload digest
89+ if : github.event_name != 'pull_request'
90+ uses : actions/upload-artifact@v4
7191 with :
72- subject-name : ${{ env.REGISTRY }}/${{ matrix.variance.image }}
73- subject-digest : ${{ steps.push.outputs.digest }}
74- push-to-registry : true
92+ name : digests-${{ matrix.variance.image }}-${{ matrix.platform.arch }}
93+ path : /tmp/digests/*
94+ if-no-files-found : error
95+ retention-days : 1
96+
97+ merge-manifests :
98+ name : Create manifest for ${{ matrix.variance.name }}
99+ runs-on : ubuntu-latest
100+ if : github.event_name != 'pull_request'
101+ needs : build-images
102+ permissions :
103+ contents : read
104+ packages : write
105+ attestations : write
106+ id-token : write
107+ strategy :
108+ fail-fast : false
109+ matrix :
110+ variance :
111+ - name : Ubuntu-22.04/CUDA-11.8.0
112+ image : " rust-gpu/rust-cuda-ubuntu22-cuda11"
113+ - name : Ubuntu-22.04/CUDA-12.8.1
114+ image : " rust-gpu/rust-cuda-ubuntu22-cuda12"
115+ - name : Ubuntu-24.04/CUDA-12.8.1
116+ image : " rust-gpu/rust-cuda-ubuntu24-cuda12"
117+ - name : RockyLinux-9/CUDA-12.8.1
118+ image : " rust-gpu/rust-cuda-rockylinux9-cuda12"
119+ steps :
120+ - name : Download digests
121+ uses : actions/download-artifact@v4
122+ with :
123+ path : /tmp/digests
124+ pattern : digests-${{ matrix.variance.image }}-*
125+ merge-multiple : true
126+ - name : Set up Docker Buildx
127+ uses : docker/setup-buildx-action@v3
128+ - name : Docker meta
129+ id : meta
130+ uses : docker/metadata-action@v5
131+ with :
132+ images : ${{ env.REGISTRY }}/${{ matrix.variance.image }}
133+ tags : |
134+ type=ref,event=branch
135+ type=sha,format=short
136+ type=raw,value=latest
137+ - name : Login to Registry
138+ uses : docker/login-action@v3
139+ with :
140+ registry : ${{ env.REGISTRY }}
141+ username : ${{ github.actor }}
142+ password : ${{ secrets.GITHUB_TOKEN }}
143+ - name : Create manifest list and push
144+ working-directory : /tmp/digests
145+ run : |
146+ docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
147+ $(printf '${{ env.REGISTRY }}/${{ matrix.variance.image }}@sha256:%s ' *)
148+ - name : Inspect image
149+ run : |
150+ docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ matrix.variance.image }}:${{ steps.meta.outputs.version }}
0 commit comments