name: Publish to PyPI

on:
  push:
    tags:
      - 'v*.*.*'

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - name: Check out the repository
      uses: actions/checkout@v3
    
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: '3.10'
    
    - name: Install UV tool
      run: curl -LsSf https://astral.sh/uv/install.sh | sh
    
    - name: Create virtual environment
      run: uv venv
    
    - name: Install dependencies
      run: uv pip install build twine
    
    - name: Build package
      run: uv pip install -e . && python -m build
    
    - name: Publish package to PyPI
      env:
        TWINE_API_KEY: ${{ secrets.PYPI_API_TOKEN }}
      run: uv twine upload dist/*
