name: release_rust

permissions:
  pull-requests: write
  contents: write

on:
  workflow_dispatch:

jobs:

  test:
    uses: ./.github/workflows/test_rust.yml

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: [test]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Publish
        if: github.ref == 'refs/heads/release'
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish
