---
name: Publish to PyPI

"on":
  push:
    branches:
      - 'master'
  workflow_dispatch:

permissions:
  contents: read

jobs:
  build:

    runs-on: ubuntu-latest

    environment: release
    permissions:
      id-token: write

    steps:
      - uses: actions/checkout@v6
      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.x'
          cache: 'pip'
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install hatch
      - name: Build package
        run: hatch build
      - name: Publish package distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        if: github.event_name == 'push' && startsWith(github.ref, 'refs/heads/2')
