name: Create Cargo Release

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

on:
  push:
    tags:
      - '[0-9]*'

jobs:
  build_and_publish:
    if: ${{ !startsWith(github.ref_name, 'py') }}
    name: Build
    runs-on: ubuntu-latest
    permissions:
      id-token: write
    environment: Cargo
    steps:
      - uses: actions/checkout@v6
      - uses: actions-rust-lang/setup-rust-toolchain@v1
      - uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Make a release
        run: cargo publish --manifest-path Cargo.toml
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}