name: Release

on:
  push:
    branches: [release]
    paths:
      - 'Cargo.toml'
      - '.github/workflows/release.yml'

permissions:
  contents: read

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@v1
        with:
          toolchain: stable

      - name: Verify package
        run: cargo package --verbose

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO }}
        run: cargo publish --no-verify
