on:
  release:
    types: [created]

name: Publish to crate

jobs:
  publish:
    name: Publish to cargo
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: nightly
          components: clippy

      - uses: Swatinem/rust-cache@v2

      - name: Test core functionality
        run: cargo test

      - uses: katyo/publish-crates@v1
        with:
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
