ci: make release workflows respect branch protection (dispatch opens PR)#165
Merged
Merged
Conversation
Both release workflows' workflow_dispatch path did `git push origin HEAD:main` to land the version-bump commit, which the branch-protection rulesets reject (GH013). This broke one-click releases — the v4.202607.0 release had to be completed manually (bump via PR + tag push). Rework the release flow into two branch-protection-safe phases: 1. workflow_dispatch -> `prepare` now calculates the version (via scripts/prepare-release.js, unchanged), commits to a `release/v<version>` branch, and opens a PR into main via `gh pr create` (no push to main). 2. Merging that PR (push to main) -> new `auto-tag` job reads package.json's version and, if untagged, creates+pushes the version tag. Tags are not branch-protected, so this succeeds and triggers the existing tag path. 3. Tag push -> resolve-version -> publish -> (mcp registry) — unchanged, and already verified working during the v4.202607.0 release. Details: - publish / publish-mcp-registry decoupled from `prepare` (now depend only on resolve-version); their Determine-version steps read resolve-version outputs unconditionally since publish only runs on the tag path now. - Job guards added so a plain main push only runs auto-tag: test and resolve-version are gated on the version-tag ref (`v*` / `agent-v*`) or dispatch; auto-tag is gated on the main-branch push. - auto-tag is idempotent (no-op when the version tag already exists), so the shared `push: branches: [main]` trigger is harmless across both workflows — each tags only when its own package version changes. - Added `pull-requests: write` permission (for `gh pr create`). - Removed the now-dead `publish_mcp_registry` dispatch input (dispatch no longer publishes directly). Applied identically to release-agent-instructions.yml (agent-v* prefix, agent-instructions/package.json).
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.
Problem
Both release workflows'
workflow_dispatchpath pushes the version-bump commit directly tomain(git push origin HEAD:main), which the branch-protection rulesets reject:This broke one-click releases —
v4.202607.0had to be completed manually (bump via PR #164 → tag push). The tag-triggered publish path already works because only branches are protected, not tags.Fix — two branch-protection-safe phases
1. Dispatch → opens a release PR (no push to main)
preparecalculates the version (scripts/prepare-release.js, unchanged), commits to arelease/v<version>branch, and opens a PR intomainviagh pr create.2. Merge PR →
auto-tag→ publishA new
auto-tagjob runs on push tomain, readspackage.json's version, and — if untagged — creates+pushes the version tag. Tags aren't branch-protected, so this succeeds and triggers the existingv*tag path →resolve-version → publish → mcp-registry(verified working during v4.202607.0).Details
publish/publish-mcp-registrydecoupled fromprepare(depend only onresolve-version); publish only runs on the tag path now.mainpush runs onlyauto-tag:test/resolve-versiongated on the version-tag ref (v*/agent-v*) or dispatch.auto-tagis idempotent (no-op when the tag exists), so the sharedpush: branches: [main]trigger is harmless — each workflow tags only when its own package version changes. Confirmed no cross-triggering (v*≠agent-v*globs).pull-requests: write; removed the now-deadpublish_mcp_registrydispatch input.release-agent-instructions.yml.New release flow (documented for maintainers)
release/v<version>PR.auto-tagtags it → publish runs, gated by the existingnpm-publishenvironment approval.Verification
yq), job guards traced for all three trigger scenarios (dispatch / main-push / tag-push).auto-tagis a safe no-op on ordinary main pushes until then.