name: upload release to PyPI
on:
  release:
    types:
      - published

jobs:
  pypi-publish:
    name: upload release to PyPI
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
      contents: write
    steps:
      - uses: actions/checkout@v4.1.1
        with:
          fetch-depth: 0
          fetch-tags: 'true'

      - uses: actions/setup-python@v2.3.1
        with:
          python-version: 3.12

      - name: Install build
        run: |
          python3 -m pip install build

      - name: Build the packages distributions
        run: |
          python3 -m build . --wheel --sdist

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