name: Build
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
validate-release-metadata:
name: Validate release metadata
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Validate release metadata (pull request)
if: github.event_name == 'pull_request'
run: |
python3 .github/scripts/validate_release_metadata.py \
--mode pull_request \
--base-sha "${{ github.event.pull_request.base.sha }}"
- name: Validate release metadata (push or dispatch)
if: github.event_name != 'pull_request'
run: |
python3 .github/scripts/validate_release_metadata.py \
--mode push_main
build-matrix:
name: Build ${{ matrix.platform }}
needs: validate-release-metadata
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux-x64-gnu
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
cross: false
- platform: linux-x64-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl
cross: true
- platform: linux-arm64-gnu
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
cross: true
- platform: macos-x64
os: macos-14
target: x86_64-apple-darwin
cross: false
- platform: macos-arm64
os: macos-14
target: aarch64-apple-darwin
cross: false
- platform: windows-x64
os: windows-latest
target: x86_64-pc-windows-msvc
cross: false
steps:
- uses: actions/checkout@v5
- name: Install Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry
uses: actions/cache@v5
with:
path: ~/.cargo/registry
key: ${{ runner.os }}-${{ matrix.target }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-registry-
- name: Cache cargo index
uses: actions/cache@v5
with:
path: ~/.cargo/git
key: ${{ runner.os }}-${{ matrix.target }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-cargo-git-
- name: Cache target directory
uses: actions/cache@v5
with:
path: target
key: ${{ runner.os }}-${{ matrix.target }}-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.target }}-target-
- name: Install cross
if: matrix.cross
run: cargo install cross --locked
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }}
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }}
- name: Upload artifacts
uses: actions/upload-artifact@v5
with:
name: x0x-${{ matrix.platform }}
path: |
target/${{ matrix.target }}/release/x0x*
!target/${{ matrix.target }}/release/*.d
!target/${{ matrix.target }}/release/*.pdb
if-no-files-found: error