.github/workflows/publish.yml

Summary

Maintainability
Test Coverage
# Publishes to PyPI upon creation of a release
name: Upload Package to PyPI

defaults:
  run:
    shell: bash

on:  # Runs everytime a release is added to the repository
  release:
    types: [created]

jobs:
  deploy:
    name: ${{ matrix.os }} / ${{ matrix.python-version }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ubuntu-latest]
        python-version: [3.9]


    steps:
      - uses: actions/checkout@v3

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'
          cache-dependency-path: '**/setup.py'

      - name: Get full Python version
        id: full-python-version
        run: echo ::set-output name=version::$(python -c "import sys; print('-'.join(str(v) for v in sys.version_info))")

      - name: Upgrade pip, setuptools, wheel, build and twine
        run: python -m pip install --upgrade pip setuptools wheel build twine

      - name: Build and check build
        run: |
          python -m build
          twine check dist/*

      - name: Publish
        if: ${{ success() }}
        env:
          TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
          TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
        run: |
          twine upload dist/*