name: Publish to PyPI

on:
  push:
    tags:
      - "v*" # Trigger on version tags like v0.2.9
  workflow_dispatch: # Allow manual trigger

jobs:
  build-and-publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

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

      - name: Install uv
        uses: astral-sh/setup-uv@v4
        with:
          version: "latest"

      - name: Build package
        run: uv build

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          # Disable OIDC trusted publishing - use API token instead
          attestations: false
          password: ${{ secrets.PYPY_API_TOKEN }}
