name: Publish package

on:
  release:
    types: [published]

jobs:
  pypi-publish:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
      with:
        fetch-depth: 0

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

    - name: Install build package
      run: |
        python -m pip install --upgrade pip
        python -m pip install build --user

    - name: Build distribution
      run: |
        python -m build --sdist --wheel --outdir dist/ .

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