diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml index 069f6cb..cdeddbb 100644 --- a/.gitea/workflows/release.yaml +++ b/.gitea/workflows/release.yaml @@ -70,15 +70,32 @@ jobs: cli: runs-on: ubuntu-latest container: - image: catthehacker/ubuntu:rust-latest + # Bundles the Rust toolchain, zig and a macOS SDK, which the generic builder images lack; + # we cross-compile every target from here with cargo-zigbuild. + image: ghcr.io/rust-cross/cargo-zigbuild:latest strategy: - fail-fast: true + fail-fast: false matrix: target: - aarch64-unknown-linux-musl - x86_64-pc-windows-gnu - x86_64-unknown-linux-musl + - universal2-apple-darwin + env: + RUSTUP_HOME: /usr/local/rustup + CARGO_HOME: /usr/local/cargo steps: + # JavaScript actions need node, which the rust-cross image does not ship. Install it (and the + # rest of the tooling the actions rely on) before anything else, as a shell step. + - name: Install Actions tooling + run: | + apt-get update + apt-get install -y --no-install-recommends ca-certificates curl git zip zstd + if ! command -v node > /dev/null; then + curl -fsSL https://deb.nodesource.com/setup_20.x | bash - + apt-get install -y --no-install-recommends nodejs + fi + - name: Checkout repository uses: actions/checkout@v4 @@ -89,19 +106,21 @@ jobs: key: rustup-cli-${{ matrix.target }}-${{ runner.os }} - name: Install Rust Toolchain - run: rustup target install ${{ matrix.target }} + run: | + if [[ "${{ matrix.target }}" == universal2-apple-darwin ]]; then + # rustc has no universal2 target of its own; cargo-zigbuild builds both architectures + # and merges them, so only the per-architecture targets need installing. + rustup target install aarch64-apple-darwin x86_64-apple-darwin + else + rustup target install ${{ matrix.target }} + fi + shell: bash - name: Cache cargo uses: Swatinem/rust-cache@v2 with: shared-key: cli-${{ matrix.target }} - - name: Cache zigbuild install - uses: actions/cache@v4 - with: - path: /opt/zigvenv - key: zigbuild-venv-${{ runner.os }} - # compiled libc/compiler-rt are per target, so these stay keyed on it - name: Cache zig build artifacts uses: actions/cache@v4 @@ -111,13 +130,6 @@ jobs: ~/.cache/cargo-zigbuild key: zigbuild-cache-${{ matrix.target }}-${{ runner.os }} - - name: Install cargo-zigbuild Toolchain - run: | - # venv keeps cargo-zigbuild and ziglang in one relocatable-by-path directory we can cache - [ -d /opt/zigvenv ] || python3 -m venv /opt/zigvenv - /opt/zigvenv/bin/pip install cargo-zigbuild - echo /opt/zigvenv/bin >> "$GITHUB_PATH" - - name: Build cli (${{ matrix.target }}) working-directory: cli run: cargo zigbuild --release --target ${{ matrix.target }}