name: PyPI

on:
  push:
    tags:
      - "[1-9]+.[0-9]+.[0-9]+"

jobs:
  release:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2

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

      - name: Prepare artifacts
        run: |
          python setup.py sdist

      - name: Publish to PyPI
        env:
          TWINE_USERNAME: __token__
          TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
        run: |
          python -m pip install twine
          twine upload dist/*
