name: Deploy to crates.io

on:
  workflow_call:
    secrets:
      CARGO_REGISTRY_TOKEN:
        required: true
jobs:
  deploy:
    name: Deploy to crates.io
    env:
      CARGO_INCREMENTAL: 0
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Cache dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.toml') }}
      - uses: katyo/publish-crates@v2
        with:
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
