| 1 | # This workflow uses actions that are not certified by GitHub. |
| 2 | # They are provided by a third-party and are governed by |
| 3 | # separate terms of service, privacy policy, and support |
| 4 | # documentation. |
| 5 | |
| 6 | # GitHub recommends pinning actions to a commit SHA. |
| 7 | # To get a newer version, you will need to update the SHA. |
| 8 | # You can also reference a tag or branch, but the action may change without warning. |
| 9 | |
| 10 | name: Upload Python Package |
| 11 | |
| 12 | on: |
| 13 | release: |
| 14 | types: [published] |
| 15 | |
| 16 | permissions: |
| 17 | contents: read |
| 18 | |
| 19 | jobs: |
| 20 | release-build: |
| 21 | runs-on: ubuntu-latest |
| 22 | |
| 23 | steps: |
| 24 | - uses: actions/checkout@v4 |
| 25 | |
| 26 | - uses: actions/setup-python@v5 |
| 27 | with: |
| 28 | python-version: "3.x" |
| 29 | |
| 30 | - name: Build release distributions |
| 31 | run: | |
| 32 | # NOTE: put your own distribution build steps here. |
| 33 | python -m pip install build |
| 34 | python -m build |
| 35 | |
| 36 | - name: Upload distributions |
| 37 | uses: actions/upload-artifact@v4 |
| 38 | with: |
| 39 | name: release-dists |
| 40 | path: dist/ |
| 41 | |
| 42 | pypi-publish: |
| 43 | runs-on: ubuntu-latest |
| 44 | |
| 45 | needs: |
| 46 | - release-build |
| 47 | |
| 48 | permissions: |
| 49 | # IMPORTANT: this permission is mandatory for trusted publishing |
| 50 | id-token: write |
| 51 | |
| 52 | # Dedicated environments with protections for publishing are strongly recommended. |
| 53 | environment: |
| 54 | name: pypi |
| 55 | # OPTIONAL: uncomment and update to include your PyPI project URL in the deployment status: |
| 56 | # url: https://pypi.org/p/YOURPROJECT |
| 57 | |
| 58 | steps: |
| 59 | - name: Retrieve release distributions |
| 60 | uses: actions/download-artifact@v4 |
| 61 | with: |
| 62 | name: release-dists |
| 63 | path: dist/ |
| 64 | |
| 65 | - name: Publish release distributions to PyPI |
| 66 | uses: pypa/gh-action-pypi-publish@release/v1 |
| 67 |