4545 build-release-image-and-linux-artifacts :
4646 name : Build Linux Artifacts and Images
4747 needs : [create-release]
48- runs-on : ubuntu-latest
48+ strategy :
49+ matrix :
50+ include :
51+ - arch : x86_64
52+ runner : ubuntu-latest
53+ - arch : aarch64
54+ runner : ubuntu-24.04-arm
55+ runs-on : ${{ matrix.runner }}
4956 permissions :
5057 contents : write
5158 packages : write
@@ -65,38 +72,71 @@ jobs:
6572 with :
6673 images : ${{ env.REGISTRY }}/${{ github.repository }}
6774 tags : |
68- type=raw,value=${{ github.ref_name }}
69- type=raw,value=latest
75+ type=raw,value=latest-${{ matrix.arch }}
76+
77+ - name : Debug Git ref
78+ run : |
79+ echo "GITHUB_REF: $GITHUB_REF"
80+ echo "GITHUB_REF_NAME: $GITHUB_REF_NAME"
81+ echo "GITHUB_SHA: $GITHUB_SHA"
82+ echo "GITHUB_REPOSITORY: $GITHUB_REPOSITORY"
7083
71- - name : Build and push multi-arch Docker images
84+ - name : Build and push Docker image
7285 uses : docker/build-push-action@v6
7386 with :
7487 file : Dockerfile
7588 context : .
7689 push : true
77- platforms : linux/amd64,linux/arm64
7890 tags : ${{ steps.meta.outputs.tags }}
7991
80- - name : Prepare Linux Binaries
92+ - name : Prepare Linux Binary
8193 shell : bash
8294 run : |
83- for arch in x86_64 aarch64; do
84- IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -- "-$arch$" | head -n 1)
85- docker create --name temp-container $IMAGE_TAG
86- docker cp temp-container:/app/${{ env.RELEASE_BIN }} ./${{ env.RELEASE_BIN }}-$arch
87- docker rm temp-container
88- tar -czf ${{ env.RELEASE_BIN }}-linux-$arch-${{ github.ref_name }}.tar.gz ${{ env.RELEASE_BIN }}-$arch
89- done
90-
91- - name : Upload Linux Release Assets
95+ IMAGE_TAG=$(echo "${{ steps.meta.outputs.tags }}" | grep -- '-${{ matrix.arch }}$' | head -n 1)
96+ docker create --name temp-container $IMAGE_TAG \
97+ && docker cp temp-container:/app/${RELEASE_BIN} ./${RELEASE_BIN} \
98+ && docker rm temp-container \
99+ && tar -czf ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz ${RELEASE_BIN}
100+
101+ - name : Upload Linux Release Asset
92102 shell : bash
93103 run : |
94- for arch in x86_64 aarch64; do
95- gh release upload "${{ github.ref_name }}" ${{ env.RELEASE_BIN }}-linux-$arch-${{ github.ref_name }}.tar.gz
96- done
104+ gh release upload "${{ github.ref_name }}" ${RELEASE_BIN}-linux-${{ matrix.arch }}-${{ github.ref_name }}.tar.gz
97105 env :
98106 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
99107
108+ create-image-manifest :
109+ name : Create Image Manifest
110+ needs : build-release-image-and-linux-artifacts
111+ runs-on : ubuntu-latest
112+ permissions :
113+ packages : write
114+ contents : read
115+ steps :
116+ - name : Log in to the Container registry
117+ uses : docker/login-action@v3
118+ with :
119+ registry : ${{ env.REGISTRY }}
120+ username : ${{ github.actor }}
121+ password : ${{ secrets.GITHUB_TOKEN }}
122+
123+ - name : Create and push manifests
124+ shell : bash
125+ run : |
126+ REPO=$(echo "${{ env.REGISTRY }}/${{ github.repository }}" | tr '[A-Z]' '[a-z]')
127+ VERSION=${REPO}:${{ github.ref_name }}
128+ LATEST=${REPO}:latest
129+
130+ docker buildx imagetools create \
131+ -t $VERSION \
132+ ${LATEST}-x86_64 \
133+ ${LATEST}-aarch64
134+
135+ docker buildx imagetools create \
136+ -t $LATEST \
137+ ${LATEST}-x86_64 \
138+ ${LATEST}-aarch64
139+
100140 build-mac-artifacts :
101141 name : Build Mac Artifacts
102142 needs : create-release
0 commit comments