name: Publish Python 🐍 distributions 📦 to TestPyPI

on:
  release:
    types: [published]
  workflow_dispatch:

jobs:
  build-n-publish:
    name: Build and publish Python 🐍 distributions 📦 to PyPI
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/aioiregul
    permissions:
      id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
    steps:
      - uses: actions/checkout@v6.0.2

      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          cache-dependency-glob: |
            **/pyproject.toml
          python-version: 3.13
      - name: Build distribution packages
        run: uv build
      - name: Publish distribution 📦 to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
