name: Publish to crates.io

on:
  push:
    branches:
      - main

jobs:
  publish:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2

      - run: cargo check --workspace --all-targets

      - name: Publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.IO_TOKEN }}
        run: cargo publish