Skip to content

Commit d97f9cb

Browse files
authored
Merge pull request foxcpp#758 from nurmukhametov/aarch64-release-binary
Build aarch64 binary in release workflow
2 parents 55cd9b0 + 96790bd commit d97f9cb

File tree

1 file changed

+45
-2
lines changed

1 file changed

+45
-2
lines changed

.github/workflows/release.yml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ permissions:
1111
packages: write
1212

1313
jobs:
14-
artifact-builder:
15-
name: "Prepare release artifacts"
14+
artifact-builder-x86:
15+
name: "Prepare release artifacts (x86)"
1616
if: github.ref_type == 'tag'
1717
runs-on: ubuntu-latest
1818
container:
@@ -55,6 +55,49 @@ jobs:
5555
uses: actions/attest-build-provenance@v2
5656
with:
5757
subject-path: '~/maddy-x86_64-linux-musl.tar.zst'
58+
artifact-builder-arm:
59+
name: "Prepare release artifacts (aarch64)"
60+
if: github.ref_type == 'tag'
61+
runs-on: ubuntu-22.04-arm
62+
steps:
63+
- name: Checkout
64+
uses: actions/checkout@v4
65+
- name: Set up Docker Buildx
66+
uses: docker/setup-buildx-action@v3
67+
# Building in a Docker container is a workaround for the issue of
68+
# JavaScript-based GitHub Actions not being supported in Alpine
69+
# containers on the Arm64 platform. Otherwise, we could completely reuse
70+
# artifact-builder-x86 as a matrix job by running it on an Arm runner.
71+
- name: Build in Docker container
72+
run: |
73+
# Create Dockerfile for the build
74+
cat > Dockerfile << 'EOF'
75+
FROM alpine:edge
76+
RUN apk add --no-cache gcc go zstd musl-dev scdoc
77+
WORKDIR /build
78+
COPY . .
79+
RUN ./build.sh --builddir /package-output/ --static build && \
80+
ver=$(cat .version) && \
81+
if [ "v$ver" != "${{github.ref_name}}" ]; then echo ".version does not match the Git tag"; exit 1; fi && \
82+
mv /package-output/ /maddy-$ver-aarch64-linux-musl && \
83+
cd / && \
84+
tar c ./maddy-$ver-aarch64-linux-musl | zstd > /maddy-aarch64-linux-musl.tar.zst
85+
EOF
86+
# Build the image, create a temporary container and copy the artifact.
87+
docker build -t maddy-builder .
88+
container_id=$(docker create maddy-builder)
89+
docker cp $container_id:/maddy-aarch64-linux-musl.tar.zst .
90+
docker rm $container_id
91+
- name: Upload binary tree
92+
uses: actions/upload-artifact@v4
93+
with:
94+
name: maddy-binary-aarch64.tar.zst
95+
path: maddy-aarch64-linux-musl.tar.zst
96+
if-no-files-found: error
97+
- name: "Generate artifact attestation"
98+
uses: actions/attest-build-provenance@v2
99+
with:
100+
subject-path: 'maddy-aarch64-linux-musl.tar.zst'
58101
docker-builder:
59102
name: "Build & push Docker image"
60103
if: github.ref_type == 'tag'

0 commit comments

Comments
 (0)