Skip to content

Commit 624e9cd

Browse files
committed
Update deployment to use trusted publishing
And modify release script accordingly
1 parent 95804d1 commit 624e9cd

File tree

2 files changed

+273
-77
lines changed

2 files changed

+273
-77
lines changed

.github/workflows/deploy.yml

+74-14
Original file line numberDiff line numberDiff line change
@@ -64,34 +64,94 @@ jobs:
6464
needs: [build_wheels, build_sdist]
6565
runs-on: ubuntu-latest
6666
# upload to PyPI on every tag starting with 'v'
67-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && contains(github.event.ref, '-rc.')
67+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && contains(github.event.ref, '-rc.')
68+
69+
environment:
70+
name: testpypi
71+
url: https://tesxt.pypi.org/p/clevercsv
72+
73+
permissions:
74+
id-token: write
75+
6876
steps:
69-
- uses: actions/download-artifact@v2
77+
- name: Download all the dists
78+
uses: actions/download-artifact@v3
7079
with:
71-
name: artifact
72-
path: dist
80+
name: python-package-distributions
81+
path: dist/
7382

74-
- uses: pypa/gh-action-pypi-publish@master
83+
- name: Publish distributions to TestPyPI
84+
uses: pypa/gh-action-pypi-publish@release/v1
7585
with:
76-
user: __token__
77-
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
7886
repository_url: https://test.pypi.org/legacy/
7987
verbose: true
8088

8189
upload_pypi:
8290
needs: [build_wheels, build_sdist]
8391
runs-on: ubuntu-latest
8492
# upload to PyPI on tags starting with 'v' that don't contain '-rc.'
85-
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && !contains(github.event.ref, '-rc.')
93+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v') && !contains(github.event.ref, '-rc.')
94+
95+
environment:
96+
name: pypi
97+
url: https://pypi.org/p/clevercsv
98+
99+
permissions:
100+
id-token: write
101+
86102
steps:
87-
- uses: actions/download-artifact@v2
103+
- name: Download all the dists
104+
uses: actions/download-artifact@v3
88105
with:
89-
name: artifact
90-
path: dist
106+
name: python-package-distributions
107+
path: dist/
91108

92-
- uses: pypa/gh-action-pypi-publish@master
109+
- name: Publish distributions to PyPI
110+
uses: pypa/gh-action-pypi-publish@release/v1
93111
with:
94-
user: __token__
95-
password: ${{ secrets.PYPI_API_TOKEN }}
96112
verbose: true
97113

114+
github-release:
115+
name: >-
116+
Sign the Python 🐍 distribution 📦 with Sigstore
117+
and upload the files to GitHub Release
118+
needs:
119+
- upload_pypi
120+
runs-on: ubuntu-latest
121+
122+
permissions:
123+
contents: write # IMPORTANT: mandatory for making GitHub Releases
124+
id-token: write # IMPORTANT: mandatory for sigstore
125+
126+
steps:
127+
- name: Download all the dists
128+
uses: actions/download-artifact@v3
129+
with:
130+
name: python-package-distributions
131+
path: dist/
132+
133+
- name: Sign the dists with Sigstore
134+
uses: sigstore/[email protected]
135+
with:
136+
inputs: >-
137+
./dist/*.tar.gz
138+
./dist/*.whl
139+
140+
- name: Create GitHub Release
141+
env:
142+
GITHUB_TOKEN: ${{ github.token }}
143+
run: >-
144+
gh release create
145+
'${{ github.ref_name }}'
146+
--notes ""
147+
148+
- name: Upload artifact signatures to GitHub Release
149+
env:
150+
GITHUB_TOKEN: ${{ github.token }}
151+
# Upload to GitHub Release using the `gh` CLI.
152+
# `dist/` contains the built packages, and the
153+
# sigstore-produced signatures and certificates.
154+
run: >-
155+
gh release upload
156+
'${{ github.ref_name }}' dist/**
157+
--repo '${{ github.repository }}'

0 commit comments

Comments
 (0)