name: Publish Crate
on:
release:
types:
- published
workflow_dispatch:
jobs:
publish:
name: cargo publish
runs-on: ubuntu-latest
environment: default
permissions:
contents: read
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Run cargo fmt
run: cargo fmt --all -- --check
- name: Run cargo clippy
run: cargo clippy --workspace --all-targets --all-features -- -D warnings
- name: Run tests
run: cargo test --workspace
- name: Build documentation
run: cargo doc --workspace --no-deps
- name: Publish to crates.io
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: cargo publish --locked --token "${CARGO_REGISTRY_TOKEN}"