name: PyPI Publish

on:
  push:
    tags:
      # Publish on any tag starting with a `v`, e.g., v0.1.0
      - v*
  workflow_dispatch:
jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
    steps:
      - name: Checkout
        uses: actions/checkout@v5
      - name: Build and smoke test
        uses: ./.github/actions/uv-build
        with:
          python-version: ${{ matrix.python-version }}

  publish:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: pypi
    permissions:
      id-token: write
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v5
      - name: Build and smoke test
        uses: ./.github/actions/uv-build
        with:
          python-version: '3.12'
      - name: Publish
        run: uv publish
