name: Rust
on:
push:
branches: ["master"]
pull_request:
branches: ["master"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: "cargo build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
cargo-fmt:
name: "cargo fmt"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Check formatting"
run: rustup component add rustfmt
- run: cargo fmt --all --check
cargo-test:
name: "cargo test"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: "Run tests"
run: cargo test
cargo-publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
needs: [build, cargo-fmt, cargo-test]
runs-on: ubuntu-latest
env:
CRATESIO_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: Publish to crates.io
run: cargo publish --token ${CRATESIO_TOKEN}