feat(ci): use cargo zibuild & xbuild
Some checks failed
Build Zenyx ⚡ / Build aarch64-unknown-linux-gnu (push) Failing after 7s
Build Zenyx ⚡ / Build universal2-apple-darwin (push) Failing after 5s
Build Zenyx ⚡ / Build x86_64-unknown-linux-gnu (push) Failing after 5s
Build Zenyx ⚡ / Build x86_64-pc-windows-msvc (push) Failing after 4s

This commit is contained in:
Chance 2025-04-18 23:22:32 -04:00
parent da1d7603d2
commit 87d810aff3
Signed by: caznix
GPG key ID: 489D213143D753FD

View file

@ -5,58 +5,32 @@ on:
pull_request: pull_request:
jobs: jobs:
setup:
name: 🔧 Setup Environment
runs-on: ubuntu-latest
outputs:
cache-hit: ${{ steps.cache-tools.outputs.cache-hit }}
steps:
- name: 📥 Checkout source
uses: https://github.com/actions/checkout@v4
- name: 🗄️ Cache tools
uses: https://github.com/actions/cache@v4
id: cache-tools
with:
path: |
~/.cargo/bin
/tmp/zig
key: tools-v1-${{ hashFiles('**/Cargo.lock') }}
- name: 🦀 Install Rust toolchain
uses: https://github.com/actions-rs/toolchain@v1
with:
toolchain: stable
components: rust-src
override: true
- name: 📦 Install Zig and cargo-zigbuild
if: steps.cache-tools.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/zig
curl -L https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz | tar -xJ -C /tmp/zig --strip-components=1
curl -L https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall -y cargo-zigbuild
build: build:
name: 🏗️ Build ${{ matrix.target }} name: Build ${{ matrix.target }}
needs: setup
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: ${{ matrix.container }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- x86_64-pc-windows-msvc
include: include:
- target: x86_64-unknown-linux-gnu - target: x86_64-unknown-linux-gnu
container: messense/cargo-zigbuild:latest
binary_name: zenyx-x86_64-linux binary_name: zenyx-x86_64-linux
ext: "" ext: ""
- target: aarch64-unknown-linux-gnu - target: aarch64-unknown-linux-gnu
container: messense/cargo-zigbuild:latest
binary_name: zenyx-aarch64-linux binary_name: zenyx-aarch64-linux
ext: "" ext: ""
- target: universal2-apple-darwin
container: messense/cargo-zigbuild:latest
binary_name: zenyx-universal-macos
ext: ""
- target: x86_64-pc-windows-msvc - target: x86_64-pc-windows-msvc
container: messense/cargo-xwin:latest
binary_name: zenyx-x86_64-windows-msvc.exe binary_name: zenyx-x86_64-windows-msvc.exe
ext: ".exe" ext: ".exe"
@ -64,42 +38,35 @@ jobs:
- name: 📥 Checkout source - name: 📥 Checkout source
uses: https://github.com/actions/checkout@v4 uses: https://github.com/actions/checkout@v4
- name: 🗄️ Restore tool cache - name: 🧩 Restore Cargo cache
uses: https://github.com/actions/cache@v4 uses: https://github.com/actions/cache@v4
with: with:
path: | path: |
~/.cargo/bin /usr/local/cargo/registry
/tmp/zig /usr/local/cargo/git
key: tools-v1-${{ hashFiles('**/Cargo.lock') }} target
key: ${{ runner.os }}-cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-${{ matrix.target }}-
- name: 📍 Add Zig to PATH - name: 🦀 Install macOS targets
run: echo "/tmp/zig" >> $GITHUB_PATH if: matrix.target == 'universal2-apple-darwin'
- name: 🎯 Install Rust target
uses: https://github.com/actions-rs/toolchain@v1 uses: https://github.com/actions-rs/toolchain@v1
with: with:
toolchain: stable target: x86_64-apple-darwin,aarch64-apple-darwin
target: ${{ matrix.target }}
override: true
- name: 🗄️ Restore Cargo cache - name: 🚀 Build project
uses: https://github.com/actions/cache@v4 run: |
with: cargo zigbuild --target ${{ matrix.target }} --release
path: | if: matrix.target != 'x86_64-pc-windows-msvc'
~/.cargo/registry
~/.cargo/git
target
key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-${{ matrix.target }}-
- name: 🚀 Build release binary - name: 🚀 Build Windows project
run: cargo zigbuild --target ${{ matrix.target }} --release run: |
cargo xwin build --target ${{ matrix.target }} --release
if: matrix.target == 'x86_64-pc-windows-msvc'
- name: 📦 Package artifact - name: 📦 Package artifact
run: | run: mkdir -p artifacts && cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}
mkdir -p artifacts
cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }}
- name: ⬆️ Upload artifact - name: ⬆️ Upload artifact
uses: https://code.forgejo.org/forgejo/upload-artifact@v4 uses: https://code.forgejo.org/forgejo/upload-artifact@v4