Skip to content

Commit

Permalink
CI: Install musl-cross tools for aarch64 cross-compilation
Browse files Browse the repository at this point in the history
Can be tested locally using `act`:

    act -W .github/workflows/deploy.yml --artifact-server-path $PWD/artifacts -j github_build --matrix os:ubuntu-latest
  • Loading branch information
badboy committed Jan 5, 2025
1 parent 60b8241 commit 20be9a1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,27 @@ jobs:
with:
targets: ${{ matrix.target }}

- name: Apt Setup on act
if: ${{ env.ACT }}
run: sudo apt update

- name: Setup | musl tools
if: ${{ endsWith(matrix.target, '-musl') }}
run: sudo apt install -y musl-tools

- name: Setup | musl cross-compile
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
pushd /tmp
wget https://github.com/musl-cross/musl-cross/releases/download/20241103/aarch64-unknown-linux-musl.tar.xz
tar -xf aarch64-unknown-linux-musl.tar.xz
echo "d3c597e89f4b87f78d473f1f6a539ed817afbce9b73a02dd123c6d5c4e43f617 *aarch64-unknown-linux-musl.tar.xz" | sha256sum -c -
ccpath=$(realpath $(find . -name aarch64-unknown-linux-musl-cc))
popd
mkdir .cargo
echo "[target.aarch64-unknown-linux-musl]" > .cargo/config.toml
printf 'linker = "%s"\n' "$ccpath" >> .cargo/config.toml
- name: Build | Build
if: ${{ ! endsWith(matrix.target, '-musl') }}
run: cargo build --release --target ${{ matrix.target }}
Expand All @@ -68,10 +85,17 @@ jobs:
run: cargo build --release --target ${{ matrix.target }}

- name: Post Setup | Extract tag name
if: ${{ !env.ACT }}
shell: bash
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})"
id: extract_tag

- name: Post Setup | Extract tag name (ACT)
if: ${{ env.ACT }}
shell: bash
run: echo "##[set-output name=tag;]v1.0.0"
id: extract_tag

- name: Post Setup | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
Expand All @@ -86,7 +110,9 @@ jobs:
run: |
mkdir target/stage
cd target/${{ matrix.target }}/release
strip ${{ env.CRATE_NAME }}
if [ "${{ matrix.target }}" != "aarch64-unknown-linux-musl" ]; then
strip ${{ env.CRATE_NAME }}
fi
tar czvf ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }}
cd -
Expand Down

0 comments on commit 20be9a1

Please sign in to comment.