.github/workflows/publish-to-pypi.yml
name: Publish to PyPI
on: push
jobs:
build-and-publish:
name: Build and publish to PyPI
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python 3
uses: actions/setup-python@v4.4.0
with:
python-version: '3.9'
- name: Install build dependencies
run: |
pip install -U setuptools wheel build
- name: Build distribution files
run: |
python -m build .
- name: Publish to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
verbose: true
- name: Publish to PyPI
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags')
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}