From 5bef4ef2ee7b576047b761ad7c7d77171bae6acb Mon Sep 17 00:00:00 2001 From: siujamo Date: Mon, 22 Jun 2026 09:56:30 +0800 Subject: [PATCH] fix(ci): switch to zigbuild for cross-compilation - Replace cross-rs with Zig toolchain and cargo-zigbuild - Add rustup target installation step for all platforms - Include --target flag in native Linux build for consistent output paths cross-rs has no Docker image for macOS targets and the Windows image ships with a broken cargo PATH, causing all non-Linux builds to fail. Zig provides its own cross-linker and ships macOS/Win libc headers, enabling cross-compilation for all three targets from a single Linux runner. --- .gitea/workflows/build.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 63d2673..334e1af 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -32,17 +32,28 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable echo "$HOME/.cargo/bin" >> "$GITHUB_PATH" + - name: Install Rust targets + run: | + rustup target add ${{ matrix.target }} + - name: Build (Linux) if: matrix.target == 'x86_64-unknown-linux-gnu' - run: cargo build --release + run: cargo build --release --target ${{ matrix.target }} - - name: Install cross + - name: Install Zig if: matrix.target != 'x86_64-unknown-linux-gnu' - run: cargo install cross --locked + run: | + curl -L -o zig.tar.xz https://ziglang.org/download/0.13.0/zig-linux-x86_64-0.13.0.tar.xz + tar xf zig.tar.xz + echo "$PWD/zig-linux-x86_64-0.13.0" >> "$GITHUB_PATH" - - name: Build with cross + - name: Install cargo-zigbuild if: matrix.target != 'x86_64-unknown-linux-gnu' - run: cross build --release --target ${{ matrix.target }} + run: cargo install cargo-zigbuild + + - name: Build with zigbuild + if: matrix.target != 'x86_64-unknown-linux-gnu' + run: cargo zigbuild --release --target ${{ matrix.target }} - name: Package run: |