name: Release to Crates.io

on:
  push:
    tags:
      - 'v[0-9]+.[0-9]+.[0-9]+'
      - 'v[0-9]+.[0-9]+.[0-9]+-*'

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

      
    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        profile: minimal
        override: true
        
     
    - name: 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
