name: Publish to crates.io
on:
  push:
    # Triggers when pushing tags starting with 'rust-v'
    tags: ["rust-v*"]

jobs:
  publish:
    runs-on: ubuntu-latest
    environment: rust-release
    permissions:
      id-token: write # Required for OIDC token exchange
    steps:
      - uses: actions/checkout@v6
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
