Skip to content

Commit 42aa204

Browse files
authored
Update release workflow to use Trusted Publishing (#10263)
1 parent 8486055 commit 42aa204

File tree

2 files changed

+50
-12
lines changed

2 files changed

+50
-12
lines changed

.github/workflows/release.yml

+47-12
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
release-pypi:
16-
name: Upload release to PyPI
15+
build:
16+
name: Build release assets
1717
runs-on: ubuntu-latest
18-
environment:
19-
name: PyPI
20-
url: https://pypi.org/project/pylint/
18+
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
2119
steps:
2220
- name: Check out code from Github
2321
uses: actions/[email protected]
@@ -31,15 +29,52 @@ jobs:
3129
run: |
3230
# Remove dist, build, and pylint.egg-info
3331
# when building locally for testing!
34-
python -m pip install twine build
32+
python -m pip install build
3533
- name: Build distributions
3634
run: |
3735
python -m build
36+
- name: Upload release assets
37+
uses: actions/[email protected]
38+
with:
39+
name: release-assets
40+
path: dist/
41+
42+
release-pypi:
43+
name: Upload release to PyPI
44+
runs-on: ubuntu-latest
45+
needs: ["build"]
46+
environment:
47+
name: PyPI
48+
url: https://pypi.org/project/pylint/
49+
permissions:
50+
id-token: write
51+
steps:
52+
- name: Download release assets
53+
uses: actions/[email protected]
54+
with:
55+
name: release-assets
56+
path: dist/
3857
- name: Upload to PyPI
3958
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
40-
env:
41-
TWINE_REPOSITORY: pypi
42-
TWINE_USERNAME: __token__
43-
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
44-
run: |
45-
twine upload --verbose dist/*
59+
uses: pypa/gh-action-pypi-publish@release/v1
60+
61+
release-github:
62+
name: Upload assets to Github release
63+
runs-on: ubuntu-latest
64+
needs: ["build"]
65+
permissions:
66+
contents: write
67+
id-token: write
68+
steps:
69+
- name: Download release assets
70+
uses: actions/[email protected]
71+
with:
72+
name: release-assets
73+
path: dist/
74+
- name: Sign the dists with Sigstore and upload assets to Github release
75+
if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags')
76+
uses: sigstore/[email protected]
77+
with:
78+
inputs: |
79+
./dist/*.tar.gz
80+
./dist/*.whl

doc/whatsnew/fragments/10256.other

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Upload release assets to PyPI via Trusted Publishing.
2+
3+
Closes #10256

0 commit comments

Comments
 (0)