name: CI/CD
on:
push:
branches:
- main
pull_request:
branches:
- main
release:
types:
- released
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
strategy:
matrix:
runner:
- ubuntu-latest
- ubuntu-24.04-arm
- windows-latest
- windows-11-arm
- macos-latest
- macos-26-intel
runs-on: ${{ matrix.runner }}
steps:
- name: Checkout
uses: actions/checkout@v6
- &cache
name: Cache
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ matrix.runner }}-cargo-${{ hashFiles('**/Cargo.toml') }}
- name: Show installed rust toolchain version
run: rustup show --verbose
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Check formatting
run: cargo fmt --check --all
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
needs: test
if: github.event_name == 'release'
steps:
- name: Checkout
uses: actions/checkout@v6
- *cache
- name: Build binary in "release" mode
run: cargo build --release
- name: Publish to crates.io
run: cargo publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}