33 branches :
44 - master
55 - develop
6- release :
7- types : [created]
86 pull_request :
9- workflow_dispatch :
107
118jobs :
129 tests :
@@ -245,9 +242,9 @@ jobs:
245242 export PATH=~/castxml/bin:$PATH
246243 pytest tests
247244
248- build-release :
245+ build :
249246 name : Build distribution 📦
250- if : (github.event_name == 'release' && github.event.action == 'created') || (github.event_name == 'workflow_dispatch')
247+ if : startsWith (github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
251248 needs : tests
252249 runs-on : ubuntu-latest
253250
@@ -273,3 +270,69 @@ jobs:
273270 with :
274271 name : python-package-distributions
275272 path : dist/
273+
274+ publish-to-pypi :
275+ name : >-
276+ Publish Python 🐍 distribution 📦 to PyPI
277+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
278+ needs :
279+ - build
280+ runs-on : ubuntu-latest
281+ environment :
282+ name : pypi
283+ url : https://pypi.org/p/<package-name> # Replace <package-name> with your PyPI project name
284+ permissions :
285+ id-token : write # IMPORTANT: mandatory for trusted publishing
286+
287+ steps :
288+ - name : Download all the dists
289+ uses : actions/download-artifact@v4
290+ with :
291+ name : python-package-distributions
292+ path : dist/
293+ - name : Publish distribution 📦 to PyPI
294+ uses : pypa/gh-action-pypi-publish@release/v1
295+
296+ github-release :
297+ name : >-
298+ Sign the Python 🐍 distribution 📦 with Sigstore
299+ and upload them to GitHub Release
300+ if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
301+ needs :
302+ - publish-to-pypi
303+ runs-on : ubuntu-latest
304+
305+ permissions :
306+ contents : write # IMPORTANT: mandatory for making GitHub Releases
307+ id-token : write # IMPORTANT: mandatory for sigstore
308+
309+ steps :
310+ - name : Download all the dists
311+ uses : actions/download-artifact@v4
312+ with :
313+ name : python-package-distributions
314+ path : dist/
315+ - name : Sign the dists with Sigstore
316+ 317+ with :
318+ inputs : >-
319+ ./dist/*.tar.gz
320+ ./dist/*.whl
321+ - name : Create GitHub Release
322+ env :
323+ GITHUB_TOKEN : ${{ github.token }}
324+ run : >-
325+ gh release create
326+ "$GITHUB_REF_NAME"
327+ --repo "$GITHUB_REPOSITORY"
328+ --notes ""
329+ - name : Upload artifact signatures to GitHub Release
330+ env :
331+ GITHUB_TOKEN : ${{ github.token }}
332+ # Upload to GitHub Release using the `gh` CLI.
333+ # `dist/` contains the built packages, and the
334+ # sigstore-produced signatures and certificates.
335+ run : >-
336+ gh release upload
337+ "$GITHUB_REF_NAME" dist/**
338+ --repo "$GITHUB_REPOSITORY"
0 commit comments