name: Publish to PyPI

on:
  push:
#    branches:
#      - main
    tags:
      - 'v*'  # Triggers only if you push a tag like v1.0.0

jobs:
  build-and-publish:
    name: Build and Publish to PyPI
    runs-on: ubuntu-latest

    steps:
      - name: Check out code
        uses: actions/checkout@v3

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

      - name: Install build dependencies
        run: python -m pip install --upgrade build

      - name: Build the package
        run: python -m build

      - name: Publish to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          password: ${{ secrets.PYPI_API_TOKEN }}
