# https://packaging.python.org/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/

name: Publish Python distribution to PyPI and TestPyPI

on: push

jobs:
  build-n-publish:
    name: Build and publish Python distribution
    runs-on: ubuntu-20.04
    steps:
    - uses: actions/checkout@master
    - name: Set up Python 3.8
      uses: actions/setup-python@v1
      with:
        python-version: 3.8
    - name: Build C library
      run: >-
        autoconf
        configure
        make
    - name: Install pypa/build
      run: >-
        python -m
        pip install
        build
        --user
    - name: Build a source tarball
      run: >-
        cd src/python
        python -m
        build
        --sdist
        --outdir dist/
        .
    - name: Publish distribution to Test PyPI
      uses: pypa/gh-action-pypi-publish@master
      with:
        password: ${{ secrets.TEST_PYPI_API_TOKEN }}
        repository_url: https://test.pypi.org/legacy/
        skip_existing: true
    - name: Publish distribution to PyPI
      if: startsWith(github.ref, 'refs/tags/py-')
      uses: pypa/gh-action-pypi-publish@master
      with:
        password: ${{ secrets.PYPI_API_TOKEN }}

Add workflow for Python packages
Add workflow for Python packages

Uploads to Test PyPI always, and to PyPI if tagged with `py-*`.
