name: Release
on:
  release:
    types: [published]
jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    permissions:
      # IMPORTANT: this permission is mandatory for trusted publishing
      id-token: write
    steps:
    - name: Checkout
      uses: actions/checkout@v4
      with:
        ref: ${{ github.event.release.tag_name }}
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: "3.x"
        check-latest: true
    - name: Install build dependencies
      run: pip install -U setuptools wheel build
    - name: Build
      run: python -m build .
    - name: Publish
      uses: pypa/gh-action-pypi-publish@release/v1
