name: Publish to PyPI

on:
  push:
    branches: [main]
  workflow_dispatch:

jobs:
  publish-pypi:
    name: Publish to PyPI
    runs-on: ubuntu-latest
    environment: kibo
    permissions:
      contents: read

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

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

      - name: Install build tools
        run: pip install build twine

      - name: Build package
        run: python -m build

      - name: Publish to PyPI
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI }}
        run: twine upload dist/*
