1
1
name : Test
2
2
on :
3
3
push :
4
+ branches :
5
+ - master
4
6
paths-ignore :
5
7
- ' doc/**'
6
8
pull_request :
31
33
- name : Checkout code
32
34
uses : actions/checkout@v4
33
35
with :
34
- fetch-depth : 1
36
+ persist-credentials : false
35
37
36
38
- name : Set up Python ${{ matrix.python-version }}
37
39
uses : astral-sh/setup-uv@v6
55
57
56
58
build :
57
59
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' }}
59
61
needs :
60
62
- tests
61
63
runs-on : ubuntu-latest
64
66
- name : Checkout code
65
67
uses : actions/checkout@v4
66
68
with :
67
- fetch-depth : 1
69
+ persist-credentials : false
70
+ fetch-depth : 0
68
71
69
72
- name : Set up Python
70
73
uses : astral-sh/setup-uv@v6
78
81
name : distributions
79
82
path : dist/
80
83
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 :
82
108
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/') }}
84
110
needs :
85
111
- build
86
112
runs-on : ubuntu-latest
@@ -102,36 +128,35 @@ jobs:
102
128
with :
103
129
verbose : true
104
130
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
-
112
131
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/') }}
115
134
runs-on : ubuntu-latest
116
135
needs :
117
- - pypi- publish
136
+ - publish-to-pypi
118
137
environment : release
119
138
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
122
141
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
129
144
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
+
135
149
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