name: Publish to PyPI

on:
  push:
    tags:
      - "v*"

permissions:
  contents: read

jobs:
  build-and-publish:
    runs-on: ubuntu-latest

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

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

      - name: Install uv
        uses: astral-sh/setup-uv@v3
        with:
          enable-cache: true

      - name: Build
        run: uv build

      - name: Publish to PyPI
        env:
          UV_PUBLISH_USERNAME: "__token__"
          UV_PUBLISH_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
        run: uv publish
