name: Publish Python Package

on:
  workflow_dispatch:
  release:
    types: [created]

jobs:
  build-n-publish:
    name: Build and publish Python 🐍 distributions 📦 to PyPI
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
    steps:
      - uses: actions/checkout@v6

      - name: Install uv
        uses: astral-sh/setup-uv@v7

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.12'

      - name: Install dependencies
        run: uv sync --all-extras

      - name: Build source and wheel archives
        run: uv build

      - name: Publish
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          verbose: true