7878 name : distributions
7979 path : dist/
8080
81- pypi-publish :
81+ publish-to-testpypi :
82+ name : Upload release to TestPyPI
83+ if : github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' # only publish to TestPyPI on push to master
84+ needs :
85+ - build
86+ runs-on : ubuntu-latest
87+ environment :
88+ name : testpypi
89+ url : https://test.pypi.org/p/sphinx-intl
90+ permissions :
91+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
92+ steps :
93+ - name : Download all the dists
94+ uses : actions/download-artifact@v4
95+ with :
96+ name : distributions
97+ path : dist/
98+ - name : Publish package distributions to TestPyPI
99+ uses : pypa/gh-action-pypi-publish@release/v1
100+ with :
101+ verbose : true
102+ repository-url : https://test.pypi.org/legacy/
103+
104+ publish-to-pypi :
82105 name : Upload release to PyPI
83106 if : github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/')
84107 needs :
@@ -102,36 +125,45 @@ jobs:
102125 with :
103126 verbose : true
104127
105- # for test
106- password : ${{ secrets.TESTPYPI_TOKEN }}
107- repository_url : https://test.pypi.org/legacy/
108-
109- # for production
110- # password: ${{ secrets.PYPI_TOKEN }}
111-
112128 github-release :
113- name : GitHub release
129+ name : Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
114130 if : github.repository_owner == 'sphinx-doc'
131+ needs :
132+ - publish-to-pypi
115133 runs-on : ubuntu-latest
116134 needs :
117135 - pypi-publish
118136 environment : release
119137 permissions :
120- contents : write # for softprops/action-gh-release to create GitHub release
121-
138+ contents : write # IMPORTANT: mandatory for making GitHub Releases
139+ id-token : write # IMPORTANT: mandatory for sigstore
122140 steps :
123- - uses : actions/checkout@v4
124- with :
125- persist-credentials : false
126- - name : Get release version
127- id : get_version
128- uses : actions/github-script@v7
141+ - name : Download all the dists
142+ uses : actions/download-artifact@v4
129143 with :
130- script : core.setOutput('version', context.ref.replace("refs/tags/", ""))
131-
132- - name : Create GitHub release
133- uses : softprops/action-gh-release@v2
134- if : startsWith(github.ref, 'refs/tags/')
144+ name : distributions
145+ path : dist/
146+ - name : Sign the dists with Sigstore
147+ 135148 with :
136- name : " sphinx-intl ${{ steps.get_version.outputs.version }}"
137- body : " Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html"
149+ inputs : >-
150+ ./dist/*.tar.gz
151+ ./dist/*.whl
152+ - name : Create GitHub Release
153+ env :
154+ GITHUB_TOKEN : ${{ github.token }}
155+ run : >-
156+ gh release create
157+ "$GITHUB_REF_NAME"
158+ --repo "$GITHUB_REPOSITORY"
159+ --notes ""
160+ - name : Upload artifact signatures to GitHub Release
161+ env :
162+ GITHUB_TOKEN : ${{ github.token }}
163+ # Upload to GitHub Release using the `gh` CLI.
164+ # `dist/` contains the built packages, and the
165+ # sigstore-produced signatures and certificates.
166+ run : >-
167+ gh release upload
168+ "$GITHUB_REF_NAME" dist/**
169+ --repo "$GITHUB_REPOSITORY"
0 commit comments