From b65f76e4dbc329f8feb90dd3d9a794fb0a3dc4e6 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Fri, 27 Mar 2026 20:22:42 +0400 Subject: [PATCH] ci: Gitea Actions build workflow for multi-arch binaries Triggers: - On tag push (v*): builds amd64, creates release with artifacts - Manual dispatch: select targets (amd64, arm64, armv7) Targets: - linux/amd64: full build with headless + audio client - linux/arm64: Raspberry Pi 4/5, cross-compiled (headless) - linux/armv7: Raspberry Pi 3/Zero 2W, cross-compiled (headless) Each target produces a tarball with: wzp-relay, wzp-client, wzp-web, wzp-bench, static/ Uses rust:1-bookworm container to match Debian 12 glibc. Cargo cache keyed on Cargo.lock for faster rebuilds. Co-Authored-By: Claude Opus 4.6 (1M context) --- .gitea/workflows/build.yml | 188 +++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100644 .gitea/workflows/build.yml diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml new file mode 100644 index 0000000..11423d9 --- /dev/null +++ b/.gitea/workflows/build.yml @@ -0,0 +1,188 @@ +name: Build Release Binaries + +on: + push: + tags: + - 'v*' + workflow_dispatch: + inputs: + targets: + description: 'Targets to build (comma-separated: amd64,arm64,armv7,mac-arm64)' + required: false + default: 'amd64' + +env: + CARGO_TERM_COLOR: always + +jobs: + # Always builds on push tags. On manual dispatch, reads inputs. + build-amd64: + if: >- + github.event_name == 'push' || + contains(github.event.inputs.targets, 'amd64') + runs-on: ubuntu-latest + container: + image: rust:1-bookworm + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: apt-get update && apt-get install -y cmake pkg-config libasound2-dev + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-amd64-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-amd64- + + - name: Build headless binaries + run: cargo build --release --bin wzp-relay --bin wzp-client --bin wzp-bench --bin wzp-web + + - name: Build audio client + run: | + cargo build --release --bin wzp-client --features audio + cp target/release/wzp-client target/release/wzp-client-audio + cargo build --release --bin wzp-client + + - name: Run tests + run: cargo test --workspace --lib + + - name: Package + run: | + mkdir -p dist/wzp-linux-amd64 + cp target/release/wzp-relay dist/wzp-linux-amd64/ + cp target/release/wzp-client dist/wzp-linux-amd64/ + cp target/release/wzp-client-audio dist/wzp-linux-amd64/ + cp target/release/wzp-web dist/wzp-linux-amd64/ + cp target/release/wzp-bench dist/wzp-linux-amd64/ + cp -r crates/wzp-web/static dist/wzp-linux-amd64/ + cd dist && tar czf wzp-linux-amd64.tar.gz wzp-linux-amd64/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: wzp-linux-amd64 + path: dist/wzp-linux-amd64.tar.gz + + build-arm64: + if: >- + github.event_name == 'push' || + contains(github.event.inputs.targets, 'arm64') + runs-on: ubuntu-latest + container: + image: rust:1-bookworm + steps: + - uses: actions/checkout@v4 + + - name: Install cross-compilation tools + run: | + dpkg --add-architecture arm64 + apt-get update + apt-get install -y cmake pkg-config gcc-aarch64-linux-gnu libc6-dev-arm64-cross + rustup target add aarch64-unknown-linux-gnu + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-arm64-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-arm64- + + - name: Build + env: + CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc + CC_aarch64_unknown_linux_gnu: aarch64-linux-gnu-gcc + run: | + cargo build --release --target aarch64-unknown-linux-gnu \ + --bin wzp-relay --bin wzp-client --bin wzp-bench --bin wzp-web + + - name: Package + run: | + mkdir -p dist/wzp-linux-arm64 + cp target/aarch64-unknown-linux-gnu/release/wzp-relay dist/wzp-linux-arm64/ + cp target/aarch64-unknown-linux-gnu/release/wzp-client dist/wzp-linux-arm64/ + cp target/aarch64-unknown-linux-gnu/release/wzp-web dist/wzp-linux-arm64/ + cp target/aarch64-unknown-linux-gnu/release/wzp-bench dist/wzp-linux-arm64/ + cp -r crates/wzp-web/static dist/wzp-linux-arm64/ + cd dist && tar czf wzp-linux-arm64.tar.gz wzp-linux-arm64/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: wzp-linux-arm64 + path: dist/wzp-linux-arm64.tar.gz + + build-armv7: + if: >- + github.event_name == 'push' || + contains(github.event.inputs.targets, 'armv7') + runs-on: ubuntu-latest + container: + image: rust:1-bookworm + steps: + - uses: actions/checkout@v4 + + - name: Install cross-compilation tools + run: | + dpkg --add-architecture armhf + apt-get update + apt-get install -y cmake pkg-config gcc-arm-linux-gnueabihf libc6-dev-armhf-cross + rustup target add armv7-unknown-linux-gnueabihf + + - name: Cache cargo + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: cargo-armv7-${{ hashFiles('Cargo.lock') }} + restore-keys: cargo-armv7- + + - name: Build + env: + CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER: arm-linux-gnueabihf-gcc + CC_armv7_unknown_linux_gnueabihf: arm-linux-gnueabihf-gcc + run: | + cargo build --release --target armv7-unknown-linux-gnueabihf \ + --bin wzp-relay --bin wzp-client --bin wzp-bench --bin wzp-web + + - name: Package + run: | + mkdir -p dist/wzp-linux-armv7 + cp target/armv7-unknown-linux-gnueabihf/release/wzp-relay dist/wzp-linux-armv7/ + cp target/armv7-unknown-linux-gnueabihf/release/wzp-client dist/wzp-linux-armv7/ + cp target/armv7-unknown-linux-gnueabihf/release/wzp-web dist/wzp-linux-armv7/ + cp target/armv7-unknown-linux-gnueabihf/release/wzp-bench dist/wzp-linux-armv7/ + cp -r crates/wzp-web/static dist/wzp-linux-armv7/ + cd dist && tar czf wzp-linux-armv7.tar.gz wzp-linux-armv7/ + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: wzp-linux-armv7 + path: dist/wzp-linux-armv7.tar.gz + + # Release job — creates a release with all artifacts when a tag is pushed + release: + if: startsWith(github.ref, 'refs/tags/v') + needs: [build-amd64] + runs-on: ubuntu-latest + steps: + - name: Download all artifacts + uses: actions/download-artifact@v4 + with: + path: artifacts + + - name: Create release + uses: softprops/action-gh-release@v2 + with: + files: artifacts/**/*.tar.gz + generate_release_notes: true