name: Publish to PyPI

on:
  workflow_dispatch:

jobs:
  publish:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write  # Required for OIDC authentication

    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
        with:
          submodules: true  # This ensures that all submodules are also checked out

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.10'  # Adjust your Python version as needed

      - name: Upgrade pip and install build tools
        run: |
          python -m pip install --upgrade pip
          pip install build twine

      - name: Build package
        run: python -m build

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