ci(pythonpublish): add workflow_dispatch trigger for republishing tags#1981
Open
bearomorphism wants to merge 2 commits intocommitizen-tools:masterfrom
Open
ci(pythonpublish): add workflow_dispatch trigger for republishing tags#1981bearomorphism wants to merge 2 commits intocommitizen-tools:masterfrom
bearomorphism wants to merge 2 commits intocommitizen-tools:masterfrom
Conversation
The publish workflow only fires on tag push. When a publish run fails and is older than 30 days, GitHub no longer allows re-running it -- the tag has to be republished some other way. Adding a `workflow_dispatch` trigger with a `ref` input lets maintainers re-publish a specific tag from the Actions UI without recreating the tag (which would also affect downstream automation). Once this lands, a maintainer can republish `v4.11.1` (commitizen-tools#1790) by triggering the workflow with `ref = v4.11.1`. Closes commitizen-tools#1790 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1981 +/- ##
=======================================
Coverage 98.23% 98.23%
=======================================
Files 61 61
Lines 2779 2779
=======================================
Hits 2730 2730
Misses 49 49 ☔ View full report in Codecov by Sentry. |
15 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a manual dispatch “escape hatch” to the PyPI publishing workflow so maintainers can re-run publishing for an existing tag (e.g., v4.11.1) when the original tag-triggered run is too old to re-run via GitHub Actions UI/API.
Changes:
- Add a
workflow_dispatchtrigger with a requiredrefinput for selecting the tag to republish. - Update the
actions/checkoutstep to use the dispatchedrefwhen present, otherwise fall back to the tag from thepushevent.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…atch
* switch ${{ inputs.ref ... }} to ${{ github.event.inputs.ref ... }} so the expression evaluates safely on push events too (avoids 'Unrecognized named-value: inputs' error)
* add a pre-checkout validation step on workflow_dispatch that fails fast if the supplied ref isn't an existing remote tag, so a branch name can't accidentally publish
* checkout via refs/tags/<ref> on dispatch as additional defence in depth
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #1790.
Why
The publish run for
v4.11.1failed at the time of the original tag push and the release is absent from PyPI — confirmed by the triage comment on #1790: "Confirmed viahttps://pypi.org/pypi/commitizen/json— 4.11.1 is not in the release history." GitHub disallows re-running workflow runs older than 30 days via the UI or API, so the original job cannot be retried.The practical recovery options are: recreate the tag (which re-fires the GitHub release workflow and risks breaking downstream automation that watches tag events), use a separate ad-hoc workflow, or add a
workflow_dispatchtrigger to the existing publish workflow so a maintainer can invoke it manually for any tag. The third option is the least invasive — it touches only the trigger block and one checkout parameter — and it becomes a permanent escape hatch for any future failed publish run without requiring tag recreation or out-of-band tooling.What changed
.github/workflows/pythonpublish.ymlworkflow_dispatchtrigger with a requiredrefstring input; update theactions/checkoutstep to use${{ inputs.ref || github.ref_name }}How it works
workflow_dispatchblock (.github/workflows/pythonpublish.yml:4–7on master, extended by the patch): a single required string input namedrefis declared, so the Actions UI presents a labelled text field when "Run workflow" is clicked. Marking itrequired: trueprevents an accidental no-argument dispatch that would fall through to an ambiguous default.refparameter changes from the hardcoded${{ github.ref_name }}at.github/workflows/pythonpublish.yml:20(master) to${{ inputs.ref || github.ref_name }}. Onpushevents theinputscontext is empty, so the expression short-circuits togithub.ref_name— the tag that triggered the push — producing identical behaviour to the previous value. Onworkflow_dispatcheventsinputs.refis the maintainer-supplied tag string and that value is used directly..github/workflows/pythonpublish.yml:11, master): theif: ${{ github.repository == 'commitizen-tools/commitizen' }}condition on thedeployjob applies to both trigger types, so forks cannot accidentally publish by dispatching this workflow.permissions: id-token: writeblock at.github/workflows/pythonpublish.yml:13–15(master) is preserved as-is. The PyPI trusted-publisher configuration accepts OIDC tokens issued forworkflow_dispatchevents on the same terms as forpushevents — no PyPI-side reconfiguration is needed.Backward compatibility
push: tags: ["v*"]trigger at.github/workflows/pythonpublish.yml:4–7(master) is unchanged; all future automatic releases behave identically.fetch-depth: 0is preserved so the full tag history remains available touv buildand to commitizen's own version introspection.uv run poe allreports no new lint or type errors.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsExpected Behavior
v4.16.0)inputs.refis empty sogithub.ref_nameis used — identical to pre-patch behaviourref = v4.11.1v4.11.1tag, runsuv build, and publishes to PyPI via the existing OIDC trusted-publisher flowdeployjob is skipped;github.repository != 'commitizen-tools/commitizen'reffieldrequired: trueis setSteps to Test This Pull Request
Additional Context
This fix was surfaced during the #1964 issue audit. The triage comment on #1790 confirmed that
v4.11.1remains absent from PyPI and that the original workflow run is too old to be re-run through the GitHub UI. Theworkflow_dispatchtrigger is intentionally minimal — a singlerefinput, no pre-flight tag validation — to keep the diff small and the blast radius low. A potential follow-up hardening would add agit describe --exact-match --tags "$ref"pre-flight check to guard against accidentally dispatching with a branch name (PyPI would reject a duplicate version upload, but the build step would still run unnecessarily); that is left as a separate issue to keep this PR focused on unblocking thev4.11.1republish.