name: CI to PyPI

on:
  push:
    tags:
      - v*.*.*

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

    steps:
      - name: Checkout
        uses: actions/checkout@v2.3.5

      - name: Setup Python
        uses: actions/setup-python@v3
        with:
          python-version: 3.8

      - name: Install pypa/build
        run: python -m pip install build --user

      - name: Build a binary wheel and a source tarball
        run: python -m build --sdist --wheel --outdir dist/ .

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