Skip to content

Commit d0f6c2c

Browse files
Use PyPI Trusted Publishing instead of API token secrets (#189)
1 parent 65c2be9 commit d0f6c2c

3 files changed

Lines changed: 43 additions & 92 deletions

File tree

.github/workflows/_pypi_publish.yaml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/_pypi_test_publish.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.

.github/workflows/cicd.yaml

Lines changed: 43 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ jobs:
7878
## Uploads the package to test.pypi.org on master if triggered by
7979
## a regular commit/push.
8080
##
81+
## Trusted Publishing does not support reusable workflows, so the publish
82+
## step runs inline here rather than in a called workflow. See
83+
## https://github.com/pypi/warehouse/issues/11096
84+
##
8185
UploadTestPyPI:
8286
if: |
8387
(
@@ -92,11 +96,29 @@ jobs:
9296
- Test
9397
- CodeQL
9498
name: Upload current version to Test PyPI
95-
uses: ./.github/workflows/_pypi_test_publish.yaml
96-
secrets:
97-
API_TOKEN: ${{ secrets.TEST_PYPI_API_TOKEN }}
99+
runs-on: ubuntu-latest
100+
permissions:
101+
id-token: write # IMPORTANT: this permission is mandatory for OIDC publishing
102+
environment:
103+
name: testpypi
104+
url: https://test.pypi.org/p/python-cmethods
105+
steps:
106+
- name: Download all the distributions
107+
uses: actions/download-artifact@v8
108+
with:
109+
name: python-package-distributions
110+
path: dist/
111+
112+
- name: Publish package distributions to Test PyPI
113+
uses: pypa/gh-action-pypi-publish@release/v1
114+
with:
115+
repository-url: https://test.pypi.org/legacy/
98116

99-
## Upload the python-kraken-sdk to Production PyPI
117+
## Upload the python-cmethods package to Production PyPI
118+
##
119+
## Trusted Publishing does not support reusable workflows, so the publish
120+
## step runs inline here rather than in a called workflow. See
121+
## https://github.com/pypi/warehouse/issues/11096
100122
##
101123
UploadPyPI:
102124
if: |
@@ -109,6 +131,20 @@ jobs:
109131
- Test
110132
- CodeQL
111133
name: Upload the current release to PyPI
112-
uses: ./.github/workflows/_pypi_publish.yaml
113-
secrets:
114-
API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
134+
runs-on: ubuntu-latest
135+
permissions:
136+
id-token: write # IMPORTANT: this permission is mandatory for OIDC publishing
137+
environment:
138+
name: pypi
139+
url: https://pypi.org/p/python-cmethods
140+
steps:
141+
- name: Download all the distributions
142+
uses: actions/download-artifact@v8
143+
with:
144+
name: python-package-distributions
145+
path: dist/
146+
147+
- name: Publish package distributions to PyPI
148+
uses: pypa/gh-action-pypi-publish@release/v1
149+
with:
150+
repository-url: https://upload.pypi.org/legacy/

0 commit comments

Comments
 (0)