name: Release to PyPI

on:
  release:
    types: [published]

permissions:
  contents: read
  id-token: write   # Required for Trusted Publishing (OIDC)

jobs:
  pypi:
    runs-on: ubuntu-latest
    environment: release

    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

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

      - name: Install build tools
        run: pip install build

      - name: Build distribution
        run: python -m build

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