From 12aea0fc26c9a4db72496a4205f9aa6137da2b48 Mon Sep 17 00:00:00 2001 From: siujamo Date: Mon, 22 Jun 2026 09:56:30 +0800 Subject: [PATCH] Replace cross-rs with cargo-zigbuild for cross-compilation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit cross-rs has no Docker image for macOS targets and the Windows image has a broken cargo PATH, causing all non-Linux builds to fail. Zig's toolchain handles Linux→macOS and Linux→Windows cross-compilation from a single ubuntu runner. Also add --target to the native Linux build so the output path matches the Package step. --- .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: |