name: Deploy Rust to Crates.io

on:
    push:
        branches: ["main"]
        paths:
            - "Cargo.toml"

env:
    CARGO_TERM_COLOR: always

jobs:
    build:
        runs-on: ubuntu-latest

        steps:
            - uses: actions/checkout@v4
            - name: Build
              run: cargo build --verbose
            - name: Run tests
              run: cargo test --verbose
            - name: Publish to crates.io
              env:
                  CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
              run: |
                  cargo publish --verbose
