-
Notifications
You must be signed in to change notification settings - Fork 30
Fix Upload to PyPI action never triggering for non-v-prefixed release tags #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ name: Build Wheels | |
| on: | ||
| push: | ||
| branches: [ main, master ] | ||
| tags: [ 'v*' ] | ||
| tags: [ 'v*', '[0-9]*' ] | ||
| pull_request: | ||
| branches: [ main, master ] | ||
| workflow_dispatch: | ||
|
|
@@ -63,7 +63,7 @@ jobs: | |
| build_sdist: | ||
| name: Build source distribution | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v5 | ||
|
|
@@ -99,7 +99,7 @@ jobs: | |
| name: Upload to PyPI | ||
| needs: [build_wheels, build_sdist] | ||
| runs-on: ubuntu-latest | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | ||
|
||
| permissions: | ||
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated
ifconditionstartsWith(github.ref, 'refs/tags/')is overly broad: it will triggerbuild_sdistandupload_pypifor any tag pushed to the repository, not just version tags. For example, pushing a tag liketest-release,debug, orhotfix-wipwould cause an upload to PyPI.The intent of the PR is to support both
v*and[0-9]*style version tags. Theifcondition should be tightened to match only those two patterns. GitHub Actions expressions supportstartsWithchecks with||, so the condition should be something like:github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/v') || github.ref =~ 'refs/tags/[0-9]')Alternatively, using a reusable condition or a dedicated helper step to set an output would work. At minimum, the condition should guard against non-version tags triggering a PyPI publish, since uploading an incorrect or untested artifact to PyPI could cause significant issues for downstream users.