name: Release

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

jobs:
  ci:
    uses: ./.github/workflows/ci.yml

  publish:
    if: github.ref_type == 'tag'
    needs: ci
    runs-on: ubuntu-latest
    permissions:
      id-token: write # Required for OIDC token exchange
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Publish crate
        run: cargo publish --features=std
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
