Skip to content

Build

Build #1

Workflow file for this run

name: Build
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-pc-windows-msvc
os: windows-latest
build-ext: .exe
artifact-ext: -x86_64-pc-windows-msvc.exe
- target: x86_64-apple-darwin
os: macos-latest
build-ext: ""
artifact-ext: -x86_64-apple-darwin
- target: aarch64-apple-darwin
os: macos-latest
build-ext: ""
artifact-ext: -aarch64-apple-darwin
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
build-ext: ""
artifact-ext: -x86_64-unknown-linux-gnu
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04-arm
build-ext: ""
artifact-ext: -aarch64-unknown-linux-gnu
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get package name from Cargo.toml
run: |
echo "PACKAGE_NAME=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].name')" >> $GITHUB_ENV
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Set up Rust cache
uses: swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Build for target
run: cargo build --release --target ${{ matrix.target }}
- name: Rename binary and output artifact name
id: rename
run: |
ARTIFACT_NAME="${PACKAGE_NAME}${{ matrix.artifact-ext }}"
mv "target/${{ matrix.target }}/release/${PACKAGE_NAME}${{ matrix.build-ext }}" "$ARTIFACT_NAME"
echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.rename.outputs.artifact_name }}
path: ${{ steps.rename.outputs.artifact_name }}
compression-level: 0