# 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@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
      - 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@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0
      - 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/*
