name: Publish Python Package

on:
  release:
    types: [published]

jobs:
  publish:
    runs-on: ubuntu-latest
    environment: pypi
    permissions:
      id-token: write # to authenticate as Trusted Publisher to pypi.org
    steps:
      - uses: actions/checkout@v5
        with:
          fetch-depth: 0
          filter: blob:none
      - uses: actions/setup-python@v5
        with:
          python-version: "3.x"
          cache: "pip"
      - run: pip install build
      - run: python -m build
      - uses: pypa/gh-action-pypi-publish@release/v1
