name: Release

on:
  release:
    types: [created]

jobs:
  publish:
    name: Publish Release
    environment: release
    runs-on: ubuntu-latest
    permissions:
      id-token: write  # IMPORTANT: this permission is mandatory for trusted publishing
    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0

    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: 3.9

    - name: Install Nox
      run: |
        python -m pip install nox

    - name: Build a binary wheel and a source tarball
      run: |
        nox -e build

    - name: Publish distribution 📦 to PyPI
      uses: pypa/gh-action-pypi-publish@release/v1
      with:
        print-hash: true
        skip-existing: true
        verify-metadata: true
