# Publish a release to crates.io.
#
# Assumed to run as a subworkflow of .github/workflows/release.yml; specifically, as a publish job
# within `cargo-dist`.
name: "Publish to crates.io"

on:
  workflow_call:
    inputs:
      plan:
        required: true
        type: string

jobs:
  crates-publish-uv:
    name: Upload uv to crates.io
    runs-on: ubuntu-latest
    environment:
      name: release
    permissions:
      contents: read
      id-token: write
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
      - uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
        id: auth
      - name: Install nightly toolchain
        # Nightly is required for the unstable `-Zpublish-timeout` flag, which lets us
        # raise the per-crate wait above the 60s default. crates.io indexing has been
        # known to lag long enough to exceed that during workspace publishes.
        run: rustup toolchain install nightly-2026-04-15 --profile minimal --no-self-update
      - name: Publish workspace crates
        # Note `--no-verify` is safe because we do a publish dry-run elsewhere in CI
        run: python3 scripts/publish-crates.py --cargo cargo +nightly-2026-04-15 --no-verify -- -Zpublish-timeout --config 'publish.timeout=600'
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
