name: Publish

on:
  release:
    types:
      - published

jobs:

  publish-package:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Set up python-3.9
        uses: actions/setup-python@v2
        with:
          python-version: 3.9
      - name: Install dependencies
        run: |
          python3 -m pip install --upgrade setuptools wheel
      - name: Build package
        run: |
          python3 setup.py sdist
          python3 setup.py bdist_wheel
      - name: Publish package to TestPyPI
        uses: pypa/gh-action-pypi-publish@v1.4.2
        with:
          user: __token__
          password: ${{ secrets.PYPI_API_TOKEN }}
