1- name : Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
1+ name : Publish Python 🐍 distribution 📦
22run-name : ${{ github.workflow }} (${{ github.ref_name }})
33
44on :
55 workflow_dispatch :
66 # FIXME: uncomment
77 push :
88 tags :
9- - " v[0-9]+.[0-9]+.[0-9]+"
9+ - " v[0-9]+.[0-9]+.[0-9]+"
10+ - " v[0-9]+.[0-9]+.[0-9]+-*"
1011
1112jobs :
1213 build :
3132 publish-to-pypi :
3233 name : >-
3334 Publish Python 🐍 distribution 📦 to PyPI
34- if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
35+ # Only publish to PyPI on tag pushes with version tags or release candidates
36+ if : startsWith(github.ref, 'refs/tags/') && (!contains(github.ref_name, '-') || contains(github.ref_name, 'rc'))
3537 needs :
3638 - build
3739 runs-on : ubuntu-latest
5355 name : >-
5456 Sign the Python 🐍 distribution 📦 with Sigstore
5557 and upload them to GitHub Release
56- if : startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
58+ # only publish to PyPI on tag pushes
59+ if : startsWith(github.ref, 'refs/tags/')
5760 needs :
5861 - build
5962 runs-on : ubuntu-latest
@@ -69,11 +72,19 @@ jobs:
6972 name : python-package-distributions
7073 path : dist/
7174 - name : Sign the dists with Sigstore
72- uses : sigstore/gh-action-sigstore-python@v2.1.1
75+ uses : sigstore/gh-action-sigstore-python@v3.0.0
7376 with :
7477 inputs : >-
7578 ./dist/*.tar.gz
7679 ./dist/*.whl
80+ - name : Determine if pre-release
81+ id : prerelease
82+ run : |
83+ if [[ "${GITHUB_REF#refs/tags/}" == *-* ]]; then
84+ echo "pre_release=true" >> $GITHUB_OUTPUT
85+ else
86+ echo "pre_release=false" >> $GITHUB_OUTPUT
87+ fi
7788 - name : Create GitHub Release
7889 env :
7990 GITHUB_TOKEN : ${{ github.token }}
8293 '${{ github.ref_name }}'
8394 --repo '${{ github.repository }}'
8495 --generate-notes
96+ --prerelease=${{ steps.prerelease.outputs.pre_release }}
8597 - name : Upload artifact signatures to GitHub Release
8698 env :
8799 GITHUB_TOKEN : ${{ github.token }}
0 commit comments