name: Publish Python Package

on:
  release:
    types: [created]

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

    steps:
    - uses: actions/checkout@v2

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

    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install wheel

    - name: build a binary wheel dist
      run: |
        rm -fr dist
        python setup.py bdist_wheel sdist

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