11name : Test
22on :
33 push :
4+ branches :
5+ - master
46 paths-ignore :
57 - ' doc/**'
68 pull_request :
3133 - name : Checkout code
3234 uses : actions/checkout@v4
3335 with :
34- fetch-depth : 1
36+ persist-credentials : false
3537
3638 - name : Set up Python ${{ matrix.python-version }}
3739 uses : astral-sh/setup-uv@v6
5557
5658 build :
5759 name : build distribution
58- if : github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master'
60+ if : ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }}
5961 needs :
6062 - tests
6163 runs-on : ubuntu-latest
6466 - name : Checkout code
6567 uses : actions/checkout@v4
6668 with :
67- fetch-depth : 1
69+ persist-credentials : false
70+ fetch-depth : 0
6871
6972 - name : Set up Python
7073 uses : astral-sh/setup-uv@v6
7881 name : distributions
7982 path : dist/
8083
81- pypi-publish :
84+ publish-to-testpypi :
85+ name : Upload release to TestPyPI
86+ if : ${{ github.repository_owner == 'sphinx-doc' && github.ref == 'refs/heads/master' }} # only publish to TestPyPI on push to master
87+ needs :
88+ - build
89+ runs-on : ubuntu-latest
90+ environment :
91+ name : testpypi
92+ url : https://test.pypi.org/p/sphinx-intl
93+ permissions :
94+ id-token : write # IMPORTANT: this permission is mandatory for trusted publishing
95+ steps :
96+ - name : Download all the dists
97+ uses : actions/download-artifact@v4
98+ with :
99+ name : distributions
100+ path : dist/
101+ - name : Publish package distributions to TestPyPI
102+ uses : pypa/gh-action-pypi-publish@release/v1
103+ with :
104+ verbose : true
105+ repository-url : https://test.pypi.org/legacy/
106+
107+ publish-to-pypi :
82108 name : Upload release to PyPI
83- if : github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/')
109+ if : ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }}
84110 needs :
85111 - build
86112 runs-on : ubuntu-latest
@@ -102,36 +128,35 @@ jobs:
102128 with :
103129 verbose : true
104130
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-
112131 github-release :
113- name : GitHub release
114- if : github.repository_owner == 'sphinx-doc'
132+ name : Sign the Python 🐍 distribution 📦 with Sigstore and upload them to GitHub Release
133+ if : ${{ github.repository_owner == 'sphinx-doc' && startsWith(github.ref, 'refs/tags/') }}
115134 runs-on : ubuntu-latest
116135 needs :
117- - pypi- publish
136+ - publish-to-pypi
118137 environment : release
119138 permissions :
120- contents : write # for softprops/action-gh-release to create GitHub release
121-
139+ contents : write # IMPORTANT: mandatory for making GitHub Releases
140+ id-token : write # IMPORTANT: mandatory for sigstore
122141 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
142+ - name : Download all the dists
143+ uses : actions/download-artifact@v4
129144 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/')
145+ name : distributions
146+ path : dist/
147+ - name : Sign the dists with Sigstore
148+ uses : sigstore/gh-action-sigstore-python@v3.0.0
135149 with :
136- name : " sphinx-intl ${{ steps.get_version.outputs.version }}"
137- body : " Changelog: https://sphinx-intl.readthedocs.io/en/master/changes.html"
150+ inputs : >-
151+ ./dist/*.tar.gz
152+ ./dist/*.whl
153+ - name : Upload artifact signatures to GitHub Release
154+ env :
155+ GITHUB_TOKEN : ${{ github.token }}
156+ # Upload to GitHub Release using the `gh` CLI.
157+ # `dist/` contains the built packages, and the
158+ # sigstore-produced signatures and certificates.
159+ run : >-
160+ gh release upload
161+ "$GITHUB_REF_NAME" dist/**
162+ --repo "$GITHUB_REPOSITORY"
0 commit comments