name: Publish Cargo Package

on:
  push:
    tags:
      - 'v*'
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - uses: actions/checkout@v7

      - uses: actions-rs/toolchain@v1
        with:
          toolchain: stable
          profile: minimal

      - name: Verify package
        run: cargo package

      - name: Publish to crates.io
        run: cargo publish --token ${{ secrets.CRATES_TOKEN }}
