11name : Build and Push Docker Image
2-
32on :
43 release :
54 types : [created]
87env :
98 REGISTRY : ghcr.io
109 IMAGE_NAME : ${{ github.repository }}
11- DOCKER_BUILDKIT : 1
1210
1311jobs :
1412 build-and-push :
@@ -17,31 +15,24 @@ jobs:
1715 include :
1816 - platform : linux/amd64
1917 runner : ubuntu-latest
18+ arch : amd64
2019 rustflags : " -C target-cpu=native"
2120 - platform : linux/arm64
2221 runner : ubuntu-22.04-arm
22+ arch : arm64
2323 rustflags : " -C codegen-units=1"
2424 runs-on : ${{ matrix.runner }}
2525 permissions :
2626 contents : read
2727 packages : write
28-
28+ outputs :
29+ digest-${{ matrix.arch }} : ${{ steps.build.outputs.digest }}
2930 steps :
3031 - name : Checkout repository
3132 uses : actions/checkout@v4
3233 with :
3334 fetch-depth : 1
3435
35- - name : Cache cargo registry and index
36- uses : actions/cache@v3
37- with :
38- path : |
39- ~/.cargo/registry
40- ~/.cargo/git
41- key : ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
42- restore-keys : |
43- ${{ runner.os }}-cargo-
44-
4536 - name : Set up Docker Buildx
4637 uses : docker/setup-buildx-action@v3
4738
@@ -53,21 +44,21 @@ jobs:
5344 password : ${{ secrets.GITHUB_TOKEN }}
5445
5546 - name : Build and push
47+ id : build
5648 uses : docker/build-push-action@v5
5749 with :
5850 context : .
5951 push : true
6052 platforms : ${{ matrix.platform }}
61- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }}-${{ matrix.platform == 'linux/amd64' && 'amd64' || 'arm64' }}
6253 cache-from : type=gha
6354 cache-to : type=gha,mode=max
6455 provenance : mode=max
6556 sbom : true
6657 build-args : |
67- BUILDKIT_INLINE_CACHE=1
68- CARGO_INCREMENTAL=0
6958 RUSTFLAGS=${{ matrix.rustflags }}
70-
59+ CARGO_INCREMENTAL=0
60+ outputs : type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
61+
7162 create-manifest :
7263 needs : build-and-push
7364 runs-on : ubuntu-latest
8172 with :
8273 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8374 tags : |
84- type=sha,prefix=
75+ type=sha
8576 type=ref,event=tag
8677 type=semver,pattern={{version}}
8778 type=semver,pattern={{major}}.{{minor}}
10495 labels : ${{ steps.meta.outputs.labels }}
10596 provenance : false
10697 load : false
107- pull : true
10898 inputs : |
109- type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}: ${{ github.sha }}-amd64 ,platform=linux/amd64
110- type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}: ${{ github.sha }}-arm64 ,platform=linux/arm64
99+ type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@ ${{ needs.build-and-push.outputs.digest-amd64 }},platform=linux/amd64
100+ type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@ ${{ needs.build-and-push.outputs.digest-arm64 }},platform=linux/arm64
0 commit comments