name: Release to Crates.io

on:
  push:
    tags:
      - 'v[0-9][1-9]*\\.[0-9][1-9]*\\.[0-9][1-9]*(-[A-Za-z]+(\\w|-)*)?'

env:
  RUST_LOG: info
  RUST_BACKTRACE: 1
  RUST_VERBOSE: --verbose

jobs:
  cargo-publish:
    name: Publishing to Cargo
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v4

      
    - name: Install Rust Toolchain
      uses: hecrj/setup-rust-action@v2
      with:
        rust-version: stable
        profile: minimal
     
    - name: Run cargo publish
      env:
        # This can help you tagging the github repository
        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        # This can help you publish to crates.io
        CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
      run: cargo publish ${{ env.RUST_VERBOSE }} --dry-run
