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

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

jobs:
  pypi-publish-uv:
    name: Upload uv to PyPI
    runs-on: ubuntu-latest
    environment:
      name: release
    permissions:
      id-token: write # For PyPI's trusted publishing
    steps:
      - name: "Install uv"
        uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          pattern: wheels_uv-*
          path: wheels_uv
          merge-multiple: true
      - name: Publish to PyPI
        run: uv publish -v wheels_uv/*

  pypi-publish-uv-build:
    name: Upload uv-build to PyPI
    runs-on: ubuntu-latest
    environment:
      name: release
    permissions:
      id-token: write # For PyPI's trusted publishing
    steps:
      - name: "Install uv"
        uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
      - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
        with:
          pattern: wheels_uv_build-*
          path: wheels_uv_build
          merge-multiple: true
      - name: Publish to PyPI
        run: uv publish -v wheels_uv_build/*
