|
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 |
| 1 | +# This is a GitHub workflow defining a set of jobs with a set of steps. ref: |
| 2 | +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions |
3 | 3 | # |
4 | | -name: Upload Python Package |
| 4 | +name: Release |
5 | 5 |
|
| 6 | +# Always tests wheel building, but only publish to PyPI on pushed tags. |
6 | 7 | on: |
7 | | - release: |
8 | | - types: [released] |
| 8 | + pull_request: |
| 9 | + paths-ignore: |
| 10 | + - "docs/**" |
| 11 | + - ".github/workflows/*.yaml" |
| 12 | + - "!.github/workflows/release.yaml" |
| 13 | + push: |
| 14 | + paths-ignore: |
| 15 | + - "docs/**" |
| 16 | + - ".github/workflows/*.yaml" |
| 17 | + - "!.github/workflows/release.yaml" |
| 18 | + branches-ignore: |
| 19 | + - "dependabot/**" |
| 20 | + - "pre-commit-ci-update-config" |
| 21 | + tags: ["**"] |
| 22 | + workflow_dispatch: |
9 | 23 |
|
10 | 24 | jobs: |
11 | | - deploy: |
12 | | - runs-on: ubuntu-latest |
| 25 | + build-release: |
| 26 | + runs-on: ubuntu-22.04 |
| 27 | + permissions: |
| 28 | + # id-token=write is required for pypa/gh-action-pypi-publish, and the PyPI |
| 29 | + # project needs to be configured to trust this workflow. |
| 30 | + # |
| 31 | + # ref: https://github.com/jupyterhub/team-compass/issues/648 |
| 32 | + # |
| 33 | + id-token: write |
13 | 34 |
|
14 | 35 | steps: |
15 | 36 | - uses: actions/checkout@v4 |
16 | 37 | - uses: actions/setup-python@v5 |
17 | 38 | with: |
18 | | - python-version: "3.x" |
| 39 | + python-version: "3.11" |
19 | 40 |
|
20 | 41 | - name: install build package |
21 | 42 | run: | |
|
27 | 48 | run: | |
28 | 49 | python -m build --sdist --wheel . |
29 | 50 | ls -l dist |
30 | | - sha256sum dist/* | tee SHA256SUMS |
31 | 51 |
|
32 | | - - name: Publish to PyPI |
33 | | - env: |
34 | | - TWINE_USERNAME: __token__ |
35 | | - TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} |
36 | | - run: | |
37 | | - pip install twine |
38 | | - twine upload --skip-existing dist/* |
| 52 | + - name: publish to pypi |
| 53 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 54 | + if: startsWith(github.ref, 'refs/tags/') |
0 commit comments