name: Build
on:
workflow_call:
inputs:
cargo-build-args:
description: 'Arguments to pass to cargo build'
required: false
type: string
default: '--all-features --all-targets'
upload-binary:
description: 'Whether to upload the binary artifact'
required: false
type: boolean
default: false
release:
description: 'Whether this is a release build (affects artifact path)'
required: false
type: boolean
default: false
require-patched-cargo:
description: 'Fail if patched Cargo.toml artifact is not found'
required: false
type: boolean
default: false
env:
CARGO_TERM_COLOR: always
jobs:
build-binary:
name: Build Binary (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 1
- name: Set up Stable Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Rust Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "ci"
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y pkg-config
- name: Download Patched Cargo.toml
id: download-cargo
uses: actions/download-artifact@v4
with:
name: patched-cargo-toml
path: .
continue-on-error: true
- name: Verify Patched Cargo.toml
if: inputs.require-patched-cargo && steps.download-cargo.outcome == 'failure'
run: |
echo "::error::Patched Cargo.toml artifact is required but was not found. Ensure patch-version ran before this job."
exit 1
- name: Build
run: cargo build ${{ inputs.cargo-build-args }}
- name: Prepare Artifact
if: inputs.upload-binary
run: |
mkdir -p artifacts
cp target/${{ inputs.release && 'release' || 'debug' }}/lab-ops artifacts/lab-ops-linux-x64
chmod +x artifacts/lab-ops-linux-x64
- name: Upload Binary Artifact
if: inputs.upload-binary
uses: actions/upload-artifact@v4
with:
name: lab-ops-linux-x64
path: artifacts/lab-ops-linux-x64