1717 IMAGE : ghcr.io/${{ github.repository }}
1818
1919jobs :
20- release :
21- runs-on : ubuntu-latest
22- timeout-minutes : 180
20+ build :
21+ strategy :
22+ fail-fast : false
23+ matrix :
24+ include :
25+ - arch : amd64
26+ runner : ubuntu-latest
27+ - arch : arm64
28+ runner : ubuntu-24.04-arm
29+
30+ runs-on : ${{ matrix.runner }}
31+ timeout-minutes : 60
2332
2433 steps :
2534 - uses : actions/checkout@v4
35+ - uses : docker/setup-buildx-action@v3
36+
37+ - uses : docker/login-action@v3
38+ with :
39+ registry : ghcr.io
40+ username : ${{ github.actor }}
41+ password : ${{ secrets.GITHUB_TOKEN }}
42+
43+ # Each architecture builds on a runner of that architecture. Emulating the PHP compile
44+ # instead took close to three hours.
45+ - name : Build and push by digest
46+ id : build
47+ uses : docker/build-push-action@v6
48+ with :
49+ context : .
50+ file : docker/Dockerfile
51+ platforms : linux/${{ matrix.arch }}
52+ cache-from : type=gha,scope=${{ matrix.arch }}
53+ cache-to : type=gha,mode=max,scope=${{ matrix.arch }}
54+ outputs : type=image,name=${{ env.IMAGE }},push-by-digest=true,name-canonical=true,push=true
2655
56+ - name : Record the digest
57+ run : |
58+ digest="${{ steps.build.outputs.digest }}"
59+ mkdir -p /tmp/digests
60+ touch "/tmp/digests/${digest#sha256:}"
61+
62+ - uses : actions/upload-artifact@v4
63+ with :
64+ name : digest-${{ matrix.arch }}
65+ path : /tmp/digests/*
66+ retention-days : 1
67+
68+ release :
69+ needs : build
70+ runs-on : ubuntu-latest
71+ timeout-minutes : 30
72+
73+ steps :
2774 - name : Resolve the version
2875 id : version
2976 run : |
3077 tag="${{ inputs.tag || github.ref_name }}"
3178 echo "tag=$tag" >> "$GITHUB_OUTPUT"
3279 echo "version=${tag#v}" >> "$GITHUB_OUTPUT"
3380
34- # PHP is compiled from source inside the image, once per architecture. The arm64 half
35- # runs under emulation, so this job is slow by nature.
36- - uses : docker/setup-qemu-action@v3
81+ - uses : actions/download-artifact@v4
82+ with :
83+ path : /tmp/digests
84+ pattern : digest-*
85+ merge-multiple : true
86+
3787 - uses : docker/setup-buildx-action@v3
3888
3989 - uses : docker/login-action@v3
@@ -42,18 +92,14 @@ jobs:
4292 username : ${{ github.actor }}
4393 password : ${{ secrets.GITHUB_TOKEN }}
4494
45- - name : Build and push the image
46- uses : docker/build-push-action@v6
47- with :
48- context : .
49- file : docker/Dockerfile
50- platforms : linux/amd64,linux/arm64
51- push : true
52- tags : |
53- ${{ env.IMAGE }}:${{ steps.version.outputs.version }}
54- ${{ env.IMAGE }}:latest
55- cache-from : type=gha
56- cache-to : type=gha,mode=max
95+ - name : Assemble the multi-architecture tags
96+ working-directory : /tmp/digests
97+ run : |
98+ docker buildx imagetools create \
99+ --tag "${IMAGE}:${{ steps.version.outputs.version }}" \
100+ --tag "${IMAGE}:latest" \
101+ $(printf "${IMAGE}@sha256:%s " *)
102+ docker buildx imagetools inspect "${IMAGE}:${{ steps.version.outputs.version }}"
57103
58104 - name : Extract the binaries
59105 run : |
@@ -62,10 +108,9 @@ jobs:
62108 image="${IMAGE}:${{ steps.version.outputs.version }}"
63109 docker pull --platform "linux/$arch" "$image"
64110 container=$(docker create --platform "linux/$arch" "$image")
65- docker cp "$container:/usr/local/bin/stoke" " dist/stoke"
111+ docker cp "$container:/usr/local/bin/stoke" dist/stoke
66112 docker rm "$container" > /dev/null
67- tar -czf "dist/stoke-${{ steps.version.outputs.version }}-linux-$arch.tar.gz" \
68- -C dist stoke
113+ tar -czf "dist/stoke-${{ steps.version.outputs.version }}-linux-$arch.tar.gz" -C dist stoke
69114 rm dist/stoke
70115 done
71116 ls -la dist
0 commit comments