8282 name : Build Package
8383 needs : lint_test # Depends on successful linting and testing
8484 # Only run this job on direct pushes to release/* branches, not on PRs
85- if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
85+ if : github.event_name == 'push' && ( startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/') )
8686 runs-on : ubuntu-latest
8787 steps :
8888 - name : Checkout code
@@ -114,8 +114,8 @@ jobs:
114114 create_release :
115115 name : Create GitHub Release
116116 needs : build # Depends on successful build
117- # Only run this job on direct pushes to release/* branches
118- if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
117+ # Only run this job on direct pushes to release/* branches or version tags
118+ if : github.event_name == 'push' && ( startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/') )
119119 runs-on : ubuntu-latest
120120 permissions :
121121 contents : write # Required to create releases and tags
@@ -129,11 +129,14 @@ jobs:
129129 name : python-package-distributions
130130 path : dist
131131
132- - name : Extract version from branch name
132+ - name : Extract version from ref
133133 id : get_version
134- # Assumes branch name is like 'release/v1.2.3'
135- # Extracts 'v1.2.3' as the tag name
136- run : echo "TAG_NAME=${GITHUB_REF#refs/heads/release/}" >> $GITHUB_OUTPUT
134+ # Works for both 'refs/heads/release/v1.2.3' and 'refs/tags/v1.2.3'
135+ run : |
136+ REF="${GITHUB_REF}"
137+ TAG="${REF#refs/heads/release/}"
138+ TAG="${TAG#refs/tags/}"
139+ echo "TAG_NAME=${TAG}" >> $GITHUB_OUTPUT
137140
138141 - name : Create GitHub Release
139142 uses : softprops/action-gh-release@v2
@@ -154,8 +157,8 @@ jobs:
154157 publish_pypi :
155158 name : Publish to PyPI
156159 needs : create_release # Depends on successful release creation
157- # Only run this job on direct pushes to release/* branches
158- if : github.event_name == 'push' && startsWith(github.ref, 'refs/heads/release/')
160+ # Only run this job on direct pushes to release/* branches or version tags
161+ if : github.event_name == 'push' && ( startsWith(github.ref, 'refs/heads/release/') || startsWith(github.ref, 'refs/tags/') )
159162 runs-on : ubuntu-latest
160163 environment : # Optional: Define environment for PyPI publishing rules/secrets
161164 name : pypi
0 commit comments