name: Publish to crates.io

on:
  push:
    tags:
      - 'v*'  # exemple : v0.1.0

jobs:
  publish:
    name: cargo publish
    runs-on: ubuntu-latest
    environment: crates_io

    steps:
      - name: Checkout code
        uses: actions/checkout@v5

      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable

      - name: Package check (dry run)
        run: cargo package

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: cargo publish --no-verify
