|
1 | | -# This workflow will upload a Python Package to PyPI when a release is created |
2 | | -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries |
3 | | - |
4 | | -# This workflow uses actions that are not certified by GitHub. |
5 | | -# They are provided by a third-party and are governed by |
6 | | -# separate terms of service, privacy policy, and support |
7 | | -# documentation. |
8 | | - |
9 | | -name: Upload Python Package |
| 1 | +name: Release |
10 | 2 |
|
11 | 3 | on: |
12 | | - release: |
13 | | - types: [published] |
14 | | - |
15 | | -permissions: |
16 | | - contents: read |
| 4 | + push: |
| 5 | + tags: |
| 6 | + # Publish on any tag starting with a `v`, e.g. v1.2.3 |
| 7 | + - v* |
17 | 8 |
|
18 | 9 | jobs: |
19 | | - release-build: |
20 | | - runs-on: ubuntu-latest |
21 | | - |
22 | | - steps: |
23 | | - - uses: actions/checkout@v4 |
24 | | - |
25 | | - - name: Install the latest version of uv |
26 | | - uses: astral-sh/setup-uv@v6 |
27 | | - |
28 | | - - uses: actions/setup-python@v5 |
29 | | - with: |
30 | | - python-version: "3.x" |
31 | | - |
32 | | - - name: Build release distributions |
33 | | - run: | |
34 | | - # NOTE: put your own distribution build steps here. |
35 | | - uv build |
36 | | -
|
37 | | - - name: Upload distributions |
38 | | - uses: actions/upload-artifact@v4 |
39 | | - with: |
40 | | - name: release-dists |
41 | | - path: dist/ |
42 | | - |
43 | | - pypi-publish: |
| 10 | + pypi: |
| 11 | + name: Publish to PyPI |
44 | 12 | runs-on: ubuntu-latest |
45 | | - needs: |
46 | | - - release-build |
| 13 | + # Environment and permissions trusted publishing. |
| 14 | + environment: |
| 15 | + # Create this environment in the GitHub repository under Settings -> Environments |
| 16 | + name: release |
47 | 17 | permissions: |
48 | | - # IMPORTANT: this permission is mandatory for trusted publishing |
49 | 18 | id-token: write |
50 | | - |
51 | | - # Dedicated environments with protections for publishing are strongly recommended. |
52 | | - # For more information, see: https://docs.github.com/en/actions/deployment/targeting-different-environments/using-environments-for-deployment#deployment-protection-rules |
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 | | - # ALTERNATIVE: if your GitHub Release name is the PyPI project version string |
59 | | - # ALTERNATIVE: exactly, uncomment the following line instead: |
60 | | - # url: https://pypi.org/project/YOURPROJECT/${{ github.event.release.name }} |
61 | | - |
62 | 19 | steps: |
63 | | - - name: Retrieve release distributions |
64 | | - uses: actions/download-artifact@v4 |
65 | | - with: |
66 | | - name: release-dists |
67 | | - path: dist/ |
68 | | - |
69 | | - - name: Publish release distributions to PyPI |
70 | | - uses: pypa/gh-action-pypi-publish@release/v1 |
71 | | - with: |
72 | | - packages-dir: dist/ |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + - uses: astral-sh/setup-uv@v3 |
| 22 | + - run: uv build |
| 23 | + - run: uv publish --trusted-publishing always |
0 commit comments