name: Crate 📦 Distribution

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true


on:
  push:

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build
    steps:
    - uses: actions/checkout@v4

    - name: '🛠️ Set up Rust'
      uses: dtolnay/rust-toolchain@stable

    - name: '🚧 Cargo test'
      run: |
        cargo test

    - name: '📦 Cargo Publish'
      if: startsWith(github.ref, 'refs/tags')
      env:
        TOKEN: ${{ secrets.CARGO_TOKEN }}
      run: |
        cargo login $TOKEN && cargo test && cargo publish