1010 release :
1111 types : [created]
1212
13+ # Add these top-level permissions
14+ permissions :
15+ contents : write
16+ id-token : write
17+
1318jobs :
1419 test :
1520 runs-on : ubuntu-latest
@@ -66,18 +71,42 @@ jobs:
6671 run : |
6772 python -m build
6873
74+ - name : Upload package distributions
75+ uses : actions/upload-artifact@v4
76+ with :
77+ name : python-package-distributions
78+ path : dist/
79+
6980 - name : Publish to PyPI
70- if : github.event_name == 'release'
81+ if : github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v')
7182 uses : pypa/gh-action-pypi-publish@release/v1
7283 with :
7384 user : __token__
7485 password : ${{ secrets.PYPI_API_TOKEN }}
7586 skip-existing : true
7687
77- - name : Publish package distributions to GitHub Releases
78- uses : python-actions /gh-release@v1
88+ - name : Sign the dists with Sigstore
89+ uses : sigstore /gh-action-sigstore-python@v3.0.0
7990 with :
80- repository : ${{ github.repository }}
81- tag_name : ${{ github.ref_name }}
82- files : |
83- dist/*
91+ inputs : >-
92+ ./dist/*.tar.gz
93+ ./dist/*.whl
94+
95+ - name : Create GitHub Release
96+ env :
97+ GITHUB_TOKEN : ${{ github.token }}
98+ run : >-
99+ gh release create
100+ "$GITHUB_REF_NAME"
101+ --repo "$GITHUB_REPOSITORY"
102+ --notes "This release was automatically created by the GitHub Actions workflow."
103+ - name : Upload artifact signatures to GitHub Release
104+ env :
105+ GITHUB_TOKEN : ${{ github.token }}
106+ # Upload to GitHub Release using the `gh` CLI.
107+ # `dist/` contains the built packages, and the
108+ # sigstore-produced signatures and certificates.
109+ run : >-
110+ gh release upload
111+ "$GITHUB_REF_NAME" dist/**
112+ --repo "$GITHUB_REPOSITORY"
0 commit comments