name: Upload Python Package

on: push

jobs:
  build-n-publish:
    name: Build and publish Python distributions to PyPI
    runs-on: ubuntu-20.04

    steps:
    - uses: actions/checkout@v3
    - name: Set up Python
      uses: actions/setup-python@v4
      with:
        python-version: "3.6"
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install setuptools wheel twine
    - name: Build a binary wheel and a source tarball
      run: |
        python setup.py sdist
        python setup.py bdist_wheel
    - name: Publish distribution to PyPI
      if: startsWith(github.ref, 'refs/tags')
      uses: pypa/gh-action-pypi-publish@master
      with:
        user: __token__
        password: ${{ secrets.PYPI_PASSWORD }}
