name: Publish to PyPI

on:
  release:
    types: [published]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.11", "3.12", "3.13"]
    steps:
      - uses: actions/checkout@v4
      - uses: astral-sh/setup-uv@v4
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync --extra dev --python ${{ matrix.python-version }}
      - run: uv run ruff check claw_forge/ tests/
      - run: uv run mypy claw_forge/ --ignore-missing-imports
      - run: uv run pytest tests/ -q --tb=short

  publish:
    runs-on: ubuntu-latest
    needs: [test]
    environment: pypi

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        uses: astral-sh/setup-uv@v4

      - name: Build
        run: uv build

      - name: Publish to PyPI
        run: uv publish --token ${{ secrets.PYPI_TOKEN }}
