name: Publish Python distributions to PyPI and TestPyPI

on:
  - push
  - workflow_dispatch

jobs:
  build-n-publish:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v2

      - name: Set up Python 3.10
        uses: actions/setup-python@v2
        with:
          python-version: '3.10'

      - name: Install Python dependencies
        run: |
          pip install --upgrade pip setuptools wheel

      - name: Build a binary wheel and a source tarball
        run: |
          python setup.py sdist bdist_wheel

      - name: Publish distribution to Test PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          password: ${{ secrets.TEST_PYPI_API_TOKEN }}
          repository_url: https://test.pypi.org/legacy/

      - name: Publish distribution to PyPI
        if: startsWith(github.ref, 'refs/tags')
        uses: pypa/gh-action-pypi-publish@release/v1
        with:
          password: ${{ secrets.PYPI_API_TOKEN }}

Add workflow to publish distributions to PyPI and TestPyPI.
CI: Add workflow to publish distributions to PyPI and TestPyPI.
