name: Build Zenyx ⚡ on: push: pull_request: 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: 🦀 Install Rust toolchain uses: https://github.com/actions-rs/toolchain@v1 with: toolchain: stable components: rust-src override: true profile: minimal - name: 🗄️ Cache tools uses: https://github.com/actions/cache@v4 id: cache-tools with: path: | ~/.cargo/bin /tmp/zig /tmp/xwin key: tools-v3-${{ hashFiles('**/Cargo.lock') }} - name: 🔧 Install build tools if: steps.cache-tools.outputs.cache-hit != 'true' run: | mkdir -p /tmp/zig /tmp/xwin curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash cargo binstall -y cargo-zigbuild cargo-xwin --no-confirm curl -L https://ziglang.org/builds/zig-linux-x86_64-0.11.0.tar.xz | tar -xJ -C /tmp/zig --strip-components=1 build: name: 🏗️ Build ${{ matrix.target }} needs: setup runs-on: ubuntu-latest strategy: fail-fast: false matrix: target: - x86_64-unknown-linux-gnu - aarch64-unknown-linux-gnu - x86_64-pc-windows-msvc include: - target: x86_64-unknown-linux-gnu binary_name: zenyx-x86_64-linux ext: "" - target: aarch64-unknown-linux-gnu binary_name: zenyx-aarch64-linux ext: "" - target: x86_64-pc-windows-msvc binary_name: zenyx-x86_64-windows-msvc.exe ext: ".exe" steps: - name: 📥 Checkout source uses: https://github.com/actions/checkout@v4 - name: 🛠️ Restore tool cache uses: https://github.com/actions/cache@v4 with: path: | ~/.cargo/bin /tmp/zig /tmp/xwin key: tools-v3-${{ hashFiles('**/Cargo.lock') }} - name: 📍 Add tools to PATH uses: https://github.com/actions-rs/toolchain@v1 with: path: ~/.cargo/bin:/tmp/zig - name: 🎯 Install Rust target uses: https://github.com/actions-rs/target@v1 with: target: ${{ matrix.target }} - name: 🗄️ Restore Cargo cache uses: https://github.com/actions/cache@v4 with: path: | ~/.cargo/registry ~/.cargo/git target key: cargo-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: | cargo-${{ matrix.target }}- - name: 🚀 Build project uses: https://github.com/actions-rs/cargo@v1 with: command: ${{ contains(matrix.target, 'windows') && 'xwin' || 'zigbuild' }} args: build --target ${{ matrix.target }} --release - name: 📦 Package artifact uses: https://github.com/actions-rs/clippy-check@v1 with: name: ${{ matrix.binary_name }} path: artifacts/${{ matrix.binary_name }} run: | mkdir -p artifacts cp target/${{ matrix.target }}/release/zenyx${{ matrix.ext }} artifacts/${{ matrix.binary_name }} - name: ⬆️ Upload artifact uses: https://code.forgejo.org/forgejo/upload-artifact@v4 with: name: ${{ matrix.binary_name }} path: artifacts/${{ matrix.binary_name }}