| 1 |
# This workflows 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 |
release: |
| 8 |
types: [published] |
| 9 |
|
| 10 |
jobs: |
| 11 |
deploy: |
| 12 |
runs-on: ubuntu-latest |
| 13 |
|
| 14 |
steps: |
| 15 |
- uses: actions/[email protected] |
| 16 |
- name: Set up Python |
| 17 |
uses: actions/[email protected] |
| 18 |
with: |
| 19 |
python-version: "3.x" |
| 20 |
- name: Install dependencies |
| 21 |
run: | |
| 22 |
python -m pip install --upgrade pip |
| 23 |
pip install build twine |
| 24 |
- name: Set package version |
| 25 |
run: | |
| 26 |
version="${{ github.event.release.tag_name }}" |
| 27 |
sed -i "s/^version = \".*\"/version = \"${version}\"/" pyproject.toml |
| 28 |
- name: Build and publish |
| 29 |
env: |
| 30 |
TWINE_USERNAME: __token__ |
| 31 |
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
| 32 |
run: | |
| 33 |
python -m build |
| 34 |
twine upload dist/* |