|
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 | +# For more information see: https://docs.github.com/en/actions/how-tos/security-for-github-actions/security-hardening-your-deployments/configuring-openid-connect-in-pypi |
3 | 2 |
|
4 | 3 | name: PyPI
|
5 | 4 |
|
6 | 5 | on:
|
7 | 6 | release:
|
8 |
| - types: [created] |
| 7 | + types: [published] |
9 | 8 |
|
10 | 9 | jobs:
|
11 |
| - deploy: |
| 10 | + release-build: |
12 | 11 | runs-on: ubuntu-latest
|
13 | 12 |
|
14 | 13 | steps:
|
15 |
| - - uses: actions/checkout@v4 |
16 |
| - - name: Set up Python |
17 |
| - uses: actions/setup-python@v5 |
18 |
| - with: |
19 |
| - python-version: "3.x" |
20 |
| - - name: Install dependencies |
21 |
| - run: | |
22 |
| - python -m pip install --upgrade pip |
23 |
| - pip install setuptools wheel twine build |
24 |
| - - name: Build and publish |
25 |
| - env: |
26 |
| - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
27 |
| - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
28 |
| - run: | |
29 |
| - python -m build --sdist --wheel . |
30 |
| - twine upload dist/* |
| 14 | + - uses: actions/checkout@v4 |
| 15 | + |
| 16 | + - uses: actions/setup-python@v5 |
| 17 | + with: |
| 18 | + python-version: "3.x" |
| 19 | + |
| 20 | + - name: Install dependencies |
| 21 | + run: | |
| 22 | + python -m pip install --upgrade pip |
| 23 | + pip install setuptools wheel build |
| 24 | +
|
| 25 | + - name: Build release distributions |
| 26 | + run: | |
| 27 | + python -m build --sdist --wheel . |
| 28 | +
|
| 29 | + - name: Upload release distributions |
| 30 | + uses: actions/upload-artifact@v4 |
| 31 | + with: |
| 32 | + name: release-dists |
| 33 | + path: dist/ |
| 34 | + |
| 35 | + pypi-publish: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + needs: |
| 38 | + - release-build |
| 39 | + permissions: |
| 40 | + id-token: write |
| 41 | + |
| 42 | + steps: |
| 43 | + - name: Retrieve release distributions |
| 44 | + uses: actions/download-artifact@v4 |
| 45 | + with: |
| 46 | + name: release-dists |
| 47 | + path: dist/ |
| 48 | + |
| 49 | + - name: Publish release distributions to PyPI |
| 50 | + uses: pypa/gh-action-pypi-publish@release/v1 |
0 commit comments