From e7114d2f5e0ed8935943be64726fc2d90464a777 Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Mon, 16 Jun 2025 16:35:18 +0000 Subject: [PATCH] feat: build for aarch64-apple-darwin, closes #62 Build for aarch64-apple-darwin in the create_release.sh script, and the GitHub workflow action --- .../workflows/create_release_and_build.yml | 12 ++++++++++- create_release.sh | 20 ++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/create_release_and_build.yml b/.github/workflows/create_release_and_build.yml index 67e569a..0b3bb1a 100644 --- a/.github/workflows/create_release_and_build.yml +++ b/.github/workflows/create_release_and_build.yml @@ -22,6 +22,9 @@ jobs: - target: arm-unknown-linux-musleabihf output_name: linux_armv6.tar.gz + - target: aarch64-apple-darwin + output_name: apple_darwin_aarch64.tar.gz + - target: x86_64-pc-windows-gnu output_name: windows_x86_64.zip @@ -38,8 +41,15 @@ jobs: - name: install cross run: cargo install cross --git https://github.com/cross-rs/cross - # Build binary + # Build binary for arm MacOS using Docker Zigbuild - name: build + if: matrix.target == 'aarch64-apple-darwin' + run: | + docker run --rm -v $(pwd):/io -w /io ghcr.io/rust-cross/cargo-zigbuild cargo zigbuild --release --target aarch64-apple-darwin + + # Build all other targets using Cross + - name: build + if: matrix.target != 'aarch64-apple-darwin' run: cross build --target ${{ matrix.target }} --release # Compress the output diff --git a/create_release.sh b/create_release.sh index 26bdc63..7e14394 100755 --- a/create_release.sh +++ b/create_release.sh @@ -231,6 +231,13 @@ cross_build_x86_windows() { cross build --target x86_64-pc-windows-gnu --release } +# Build, using zig-build, for Apple silicon +zig_build_aarch64_apple() { + # mkdir /workspace/oxker/target + echo -e "${YELLOW}docker run --rm -v $(pwd):/io -w /io ghcr.io/rust-cross/cargo-zigbuild cargo zigbuild --release --target aarch64-apple-darwin${RESET}" + docker run --rm -v "$(pwd):/io" -w /io ghcr.io/rust-cross/cargo-zigbuild cargo zigbuild --release --target aarch64-apple-darwin +} + # Build all releases that GitHub workflow would # This will download GB's of docker images cross_build_all() { @@ -243,6 +250,8 @@ cross_build_all() { ask_continue cross_build_x86_windows ask_continue + zig_build_aarch64_apple + ask_continue } # $1 text to colourise @@ -377,8 +386,9 @@ build_choice() { 1 "x86 musl linux" off 2 "aarch64 musl linux" off 3 "armv6 musl linux" off - 4 "x86 windows" off - 5 "all" off + 4 "aarch64 apple" off + 5 "x86 windows" off + 6 "all" off ) choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty) exitStatus=$? @@ -404,10 +414,14 @@ build_choice() { exit ;; 4) - cross_build_x86_windows + zig_build_aarch64_apple exit ;; 5) + cross_build_x86_windows + exit + ;; + 6) cross_build_all exit ;;