3131 - name : Checkout
3232 uses : actions/checkout@v4
3333
34- # We don't need QEMU since we're running on native hardware.
34+ # Set up Docker Buildx
3535 - name : Set up Docker Buildx
3636 uses : docker/setup-buildx-action@v3
3737
@@ -42,23 +42,15 @@ jobs:
4242 username : ${{ github.actor }}
4343 password : ${{ secrets.GITHUB_TOKEN }}
4444
45- - name : Generate build ID
46- id : prep
47- run : |
48- branch=${GITHUB_REF##*/}
49- sha=${GITHUB_SHA::8}
50- ts=$(date +%s)
51- echo "BUILD_ID=${branch}-${sha}-${ts}" >> $GITHUB_OUTPUT
52-
45+ # Use docker/metadata-action to generate tags with an architecture suffix
5346 - name : Extract Docker metadata
5447 id : meta
5548 uses : docker/metadata-action@v5
5649 with :
5750 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
5851 tags : |
59- type=raw,value=latest
60- type=raw,value=${{ steps.prep.outputs.BUILD_ID }}
61- type=raw,value=${{ inputs.version }}
52+ type=raw,value=latest-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
53+ type=raw,value=${{ inputs.version }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
6254
6355 - name : Build and push Docker image for ${{ matrix.platform }}
6456 uses : docker/build-push-action@v6
7062 tags : ${{ steps.meta.outputs.tags }}
7163 labels : ${{ steps.meta.outputs.labels }}
7264
73- release :
65+ manifest :
7466 needs : build
7567 runs-on : ubuntu-latest
68+ permissions :
69+ contents : read
70+ packages : write
71+ steps :
72+ - name : Log into registry ${{ env.REGISTRY }}
73+ uses : docker/login-action@v3
74+ with :
75+ registry : ${{ env.REGISTRY }}
76+ username : ${{ github.actor }}
77+ password : ${{ secrets.GITHUB_TOKEN }}
78+
79+ # Create a multi-arch manifest for the "latest" tag
80+ - name : Create multi-arch manifest for latest
81+ run : |
82+ docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest \
83+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-amd64 \
84+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest-arm64
85+ docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
86+
87+ # Create a multi-arch manifest for the version tag
88+ - name : Create multi-arch manifest for version tag
89+ run : |
90+ docker manifest create ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }} \
91+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-amd64 \
92+ ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}-arm64
93+ docker manifest push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ inputs.version }}
94+
95+ release :
96+ needs : manifest
97+ runs-on : ubuntu-latest
7698 steps :
7799 - uses : actions/checkout@v4
78100
0 commit comments