name: Rust - Build, test and publish
on:
push:
branches: [ "master" ]
tags: ['v*'] pull_request:
branches: [ "master" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- host: ubuntu-latest
target: x86_64-unknown-linux-gnu
artifact_name: sentencex
asset_name: sentencex-linux-amd64
- host: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
artifact_name: sentencex
asset_name: sentencex-linux-arm64
- host: windows-latest
target: x86_64-pc-windows-msvc
artifact_name: sentencex.exe
asset_name: sentencex-windows-amd64.exe
- host: macos-15-intel
target: x86_64-apple-darwin
artifact_name: sentencex
asset_name: sentencex-macos-amd64
- host: macos-latest
target: aarch64-apple-darwin
artifact_name: sentencex
asset_name: sentencex-macos-arm64
runs-on: ${{ matrix.host }}
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --release --target ${{ matrix.target }} --verbose
- name: Run tests
run: cargo test --verbose
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: target/${{ matrix.target }}/release/${{ matrix.artifact_name }}
if-no-files-found: error
publish:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: build
environment: release permissions:
id-token: write steps:
- uses: actions/checkout@v6
- uses: rust-lang/crates-io-auth-action@v1
id: auth
- run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}