@@ -43,17 +43,14 @@ jobs:
4343 strategy :
4444 matrix :
4545 include :
46- # Linux x86_64
46+ # AMD64 native
4747 - os : ubuntu-latest
48- target : x86_64-unknown-linux-gnu
49- arch : x86_64
50- platform : linux
51-
52- # Linux ARM64 (cross-compile)
48+ arch : amd64
49+ platforms : linux/amd64
50+ # ARM64 native
5351 - os : ubuntu-latest
54- target : aarch64-unknown-linux-gnu
5552 arch : arm64
56- platform : linux
53+ platforms : linux/arm64
5754 runs-on : ${{ matrix.os }}
5855 steps :
5956 - uses : actions/checkout@v6
6764 fi
6865 echo "CLEANED_REF_NAME=$REF_NAME_CLEAN" >> $GITHUB_ENV
6966
70- - uses : docker/setup-qemu-action@v3
67+ - name : Set up QEMU
68+ if : matrix.arch == 'arm64'
69+ uses : docker/setup-qemu-action@v3
7170 - uses : docker/setup-buildx-action@v3
7271 - uses : docker/login-action@v3
7372 with :
@@ -87,15 +86,47 @@ jobs:
8786 with :
8887 context : .
8988 push : true
90- platforms : linux/amd64,linux/arm64
89+ platforms : ${{ matrix.platforms }}
9190 tags : ${{ github.repository }}:latest,${{ github.repository }}:${{ github.ref_name }}
9291 build-args : VERSION_ARG=v${{ github.ref_name }}
92+ cache-from : type=registry,ref=${{ github.repository }}:cache
93+ cache-to : type=registry,ref=${{ github.repository }}:cache,mode=max
9394
9495 - uses : docker/build-push-action@v6
9596 if : startsWith(github.ref, 'refs/heads/')
9697 with :
9798 context : .
9899 push : true
99- platforms : linux/amd64,linux/arm64
100+ platforms : ${{ matrix.platforms }}
100101 tags : ${{ github.repository }}:${{ env.CLEANED_REF_NAME }}
101102 build-args : VERSION_ARG=${{ github.sha }}@${{ env.CLEANED_REF_NAME }}
103+ cache-from : type=registry,ref=${{ github.repository }}:cache
104+ cache-to : type=registry,ref=${{ github.repository }}:cache,mode=max
105+
106+ docker-manifest :
107+ if : github.event_name != 'pull_request'
108+ needs : build-docker
109+ runs-on : ubuntu-latest
110+ steps :
111+ - uses : actions/checkout@v6
112+ - uses : docker/login-action@v3
113+ with :
114+ username : ${{ secrets.DOCKERHUB_USERNAME }}
115+ password : ${{ secrets.DOCKERHUB_TOKEN }}
116+
117+ - name : Create multi-arch manifest for tags
118+ if : startsWith(github.ref, 'refs/tags/')
119+ run : |
120+ docker buildx imagetools create \
121+ -t ${{ github.repository }}:latest \
122+ ${{ github.repository }}:latest
123+ docker buildx imagetools create \
124+ -t ${{ github.repository }}:${{ github.ref_name }} \
125+ ${{ github.repository }}:${{ github.ref_name }}
126+
127+ - name : Create multi-arch manifest for branches
128+ if : startsWith(github.ref, 'refs/heads/')
129+ run : |
130+ docker buildx imagetools create \
131+ -t ${{ github.repository }}:${{ env.CLEANED_REF_NAME }} \
132+ ${{ github.repository }}:${{ env.CLEANED_REF_NAME }}
0 commit comments