2929 strategy :
3030 matrix :
3131 arch : [amd64, arm64]
32+ variant : [cpu, cuda]
3233 fail-fast : false
3334 steps :
3435 - name : Checkout code
@@ -54,10 +55,10 @@ jobs:
5455 with :
5556 images : ghcr.io/${{ github.repository }}
5657 tags : |
57- type=raw,value=latest ,enable=${{ github.ref == 'refs/heads/main' }}
58- type=ref,event=pr
59- type=ref,event=tag
60- type=sha,format=short
58+ type=raw,value=${{ matrix.variant }}-${{ matrix.arch }} ,enable=${{ github.ref == 'refs/heads/main' }}
59+ type=raw,value=${{ matrix.variant }}-${{ matrix.arch }}-pr-${{ github.event.pull_request.number }},enable=${{ github.event_name == 'pull_request' }}
60+ type=raw,value=${{ matrix.variant }}-${{ matrix.arch }}-${{ github.ref_name }},enable=${{ startsWith(github.ref, 'refs/tags/') }}
61+ type=raw,value=${{ matrix.variant }}-${{ matrix.arch }}-sha-${{ github.sha }}
6162
6263 - name : Build and push
6364 uses : docker/build-push-action@v6
6667 platforms : linux/${{ matrix.arch }}
6768 push : ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
6869 tags : ${{ steps.meta.outputs.tags }}
69- labels : ${{ steps.meta.outputs.labels }}
70+ provenance : false
71+ build-args : |
72+ PYTORCH_VARIANT=${{ matrix.variant }}
73+
74+ create-manifests :
75+ needs : build-and-push
76+ runs-on : ubuntu-latest
77+ if : github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
78+ permissions :
79+ packages : write
80+ steps :
81+ - name : Set up QEMU
82+ uses : docker/setup-qemu-action@v3
83+
84+ - name : Setup Docker Buildx
85+ uses : docker/setup-buildx-action@v3
86+ with :
87+ driver-opts : |
88+ image=moby/buildkit:latest
89+ network=host
90+
91+ - name : Log in to GHCR
92+ uses : docker/login-action@v3
93+ with :
94+ registry : ghcr.io
95+ username : ${{ github.actor }}
96+ password : ${{ secrets.GITHUB_TOKEN }}
97+
98+ - name : Create and push CPU manifest
99+ run : |
100+ # Determine the correct tag suffixes based on the event type
101+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
102+ # PR build - use the commit SHA for more predictable references
103+ AMD64_TAG="cpu-amd64-sha-${{ github.sha }}"
104+ ARM64_TAG="cpu-arm64-sha-${{ github.sha }}"
105+ TARGET_TAG="cpu-sha-${{ github.sha }}"
106+ elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
107+ # Tag build - use tag version in the name
108+ AMD64_TAG="cpu-amd64-${{ github.ref_name }}"
109+ ARM64_TAG="cpu-arm64-${{ github.ref_name }}"
110+ TARGET_TAG="cpu-${{ github.ref_name }}"
111+ else
112+ # Main branch build - use simple arch tags
113+ AMD64_TAG="cpu-amd64"
114+ ARM64_TAG="cpu-arm64"
115+ TARGET_TAG="cpu"
116+ fi
117+
118+ # Create the manifest with the correct tag names
119+ echo "Creating CPU manifest using $AMD64_TAG and $ARM64_TAG"
120+ docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${TARGET_TAG} \
121+ ghcr.io/${{ github.repository }}:${AMD64_TAG} \
122+ ghcr.io/${{ github.repository }}:${ARM64_TAG}
123+
124+ # If on main branch, also tag as latest
125+ if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then
126+ docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:latest \
127+ ghcr.io/${{ github.repository }}:${AMD64_TAG} \
128+ ghcr.io/${{ github.repository }}:${ARM64_TAG}
129+ fi
130+
131+ - name : Create and push CUDA manifest
132+ run : |
133+ # Determine the correct tag suffixes based on the event type
134+ if [[ "${{ github.event_name }}" == "pull_request" ]]; then
135+ # PR build - use the commit SHA for more predictable references
136+ AMD64_TAG="cuda-amd64-sha-${{ github.sha }}"
137+ ARM64_TAG="cuda-arm64-sha-${{ github.sha }}"
138+ TARGET_TAG="cuda-sha-${{ github.sha }}"
139+ elif [[ "${{ startsWith(github.ref, 'refs/tags/') }}" == "true" ]]; then
140+ # Tag build - use tag version in the name
141+ AMD64_TAG="cuda-amd64-${{ github.ref_name }}"
142+ ARM64_TAG="cuda-arm64-${{ github.ref_name }}"
143+ TARGET_TAG="cuda-${{ github.ref_name }}"
144+ else
145+ # Main branch build - use simple arch tags
146+ AMD64_TAG="cuda-amd64"
147+ ARM64_TAG="cuda-arm64"
148+ TARGET_TAG="cuda"
149+ fi
150+
151+ # Create the manifest with the correct tag names
152+ echo "Creating CUDA manifest using $AMD64_TAG and $ARM64_TAG"
153+ docker buildx imagetools create --tag ghcr.io/${{ github.repository }}:${TARGET_TAG} \
154+ ghcr.io/${{ github.repository }}:${AMD64_TAG} \
155+ ghcr.io/${{ github.repository }}:${ARM64_TAG}
0 commit comments