14
14
REGISTRY : ghcr.io
15
15
jobs :
16
16
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 }}
19
19
permissions :
20
20
contents : read
21
21
packages : write
22
- attestations : write
23
- id-token : write
24
22
strategy :
25
23
fail-fast : false
26
24
matrix :
25
+ platform :
26
+ - runner : ubuntu-latest
27
+ arch : amd64
28
+ - runner : ubuntu-24.04-arm
29
+ arch : arm64
27
30
variance :
28
31
- name : Ubuntu-22.04/CUDA-11.8.0
29
- image : " ${{ github.repository }} -ubuntu22-cuda11"
32
+ image : " rust-gpu/rust-cuda -ubuntu22-cuda11"
30
33
dockerfile : ./container/ubuntu22-cuda11/Dockerfile
31
34
- name : Ubuntu-22.04/CUDA-12.8.1
32
- image : " ${{ github.repository }} -ubuntu22-cuda12"
35
+ image : " rust-gpu/rust-cuda -ubuntu22-cuda12"
33
36
dockerfile : ./container/ubuntu22-cuda12/Dockerfile
34
37
- name : Ubuntu-24.04/CUDA-12.8.1
35
- image : " ${{ github.repository }} -ubuntu24-cuda12"
38
+ image : " rust-gpu/rust-cuda -ubuntu24-cuda12"
36
39
dockerfile : ./container/ubuntu24-cuda12/Dockerfile
37
40
- name : RockyLinux-9/CUDA-12.8.1
38
- image : " ${{ github.repository }} -rockylinux9-cuda12"
41
+ image : " rust-gpu/rust-cuda -rockylinux9-cuda12"
39
42
dockerfile : ./container/rockylinux9-cuda12/Dockerfile
40
43
steps :
41
44
- name : Checkout repository
42
45
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 }}"
43
58
- name : Log in to the Container registry
44
59
uses : docker/login-action@v3
45
60
with :
@@ -51,24 +66,85 @@ jobs:
51
66
uses : docker/metadata-action@v5
52
67
with :
53
68
images : ${{ env.REGISTRY }}/${{ matrix.variance.image }}
54
- tags : |
55
- type=ref,event=branch
56
- type=sha,format=short
57
- type=raw,value=latest
58
69
- name : Set up Docker Buildx
59
70
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
62
73
uses : docker/build-push-action@v6
63
74
with :
64
75
context : .
65
76
file : ${{ matrix.variance.dockerfile }}
66
- tags : ${{ steps.meta.outputs.tags }}
77
+ platforms : linux/ ${{ matrix.platform.arch }}
67
78
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
71
91
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