Use this GitHub Action to upload a Python package to PyPI.
In your repository, add the following lines to .github/workflows/release.yml
:
on:
release:
types: [published]
name: Release
jobs:
pypi:
name: Release to PyPI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Upload to PyPI
uses: FeatureLabs/gh-action-pypi-upload@v1
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
TEST_PYPI_USERNAME: ${{ secrets.TEST_PYPI_USERNAME }}
TEST_PYPI_PASSWORD: ${{ secrets.TEST_PYPI_PASSWORD }}
Then, add the following secrets to the repository settings:
PYPI_USERNAME
PYPI_PASSWORD
TEST_PYPI_USERNAME
TEST_PYPI_PASSWORD
The published release tag from GitHub will determine which repository the package is uploaded to. The tag schemes are based on the specifications in PEP 440.
To upload a package to Test PyPI, the tag must follow the version schemes for developmental releases.
X.Y.devN # Developmental release
X.YaN.devM # Developmental release of an alpha release
X.YbN.devM # Developmental release of a beta release
X.YrcN.devM # Developmental release of a release candidate
X.Y.postN.devM # Developmental release of a post-release
To upload a package to PyPI, the tag can follow version schemes for pre-releases, final releases, or post-releases.
X.YaN # Alpha release
X.YbN # Beta release
X.YrcN # Release Candidate
X.Y # Final release
X.Y.postN # Post-release
X.YaN.postM # Post-release of an alpha release
X.YbN.postM # Post-release of a beta release
X.YrcN.postM # Post-release of a release candidate
Note: Once you release a version of your package to PyPI, you cannot rerelease that same version number even if you delete it.