| 1 |
# This workflow will upload a Python Package using Twine when a release is created |
| 2 |
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries |
| 3 |
|
| 4 |
name: Upload Python Package |
| 5 |
|
| 6 |
on: |
| 7 |
workflow_dispatch: |
| 8 |
release: |
| 9 |
types: [published] |
| 10 |
|
| 11 |
permissions: |
| 12 |
contents: read |
| 13 |
|
| 14 |
jobs: |
| 15 |
deploy: |
| 16 |
|
| 17 |
runs-on: ubuntu-latest |
| 18 |
|
| 19 |
steps: |
| 20 |
- uses: actions/checkout@v3 |
| 21 |
- name: Set up Python |
| 22 |
uses: actions/setup-python@v3 |
| 23 |
with: |
| 24 |
python-version: '3.x' |
| 25 |
|
| 26 |
- name: Install dependencies |
| 27 |
run: | |
| 28 |
python -m pip install --upgrade pip |
| 29 |
pip install build |
| 30 |
|
| 31 |
- name: Build package |
| 32 |
run: python -m build |
| 33 |
|
| 34 |
- name: Publish package to PyPI |
| 35 |
if: github.event_name == 'release' |
| 36 |
uses: pypa/[email protected] |
| 37 |
with: |
| 38 |
user: __token__ |
| 39 |
password: ${{ secrets.PYPI_API_TOKEN }} |
| 40 |
|
| 41 |
- name: Publish package to Test PyPI |
| 42 |
if: github.event_name == 'workflow_dispatch' |
| 43 |
uses: pypa/[email protected] |
| 44 |
with: |
| 45 |
password: ${{ secrets.TEST_PYPI_API_TOKEN }} |
| 46 |
repository-url: https://test.pypi.org/legacy/ |