name: Publish to PyPI

on:
  release:
    types: [published]

permissions:
  contents: read
  pages: write
  id-token: write

jobs:
  ci:
    uses: ./.github/workflows/ci.yml
    permissions:
      contents: read
      pages: write
      id-token: write

  publish:
    needs: ci
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v5
        with:
          version: "latest"

      - name: Set up Python
        run: uv python install 3.12

      - name: Build package
        run: uv build

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
