Skip to content

Fix releases on protected branches - #31

Merged
kayodebristol merged 1 commit into
mainfrom
codex/protected-release-pipeline
Aug 11, 2026
Merged

Fix releases on protected branches#31
kayodebristol merged 1 commit into
mainfrom
codex/protected-release-pipeline

Conversation

@kayodebristol

Copy link
Copy Markdown
Contributor

What changed

The shared release workflow now prepares version and changelog changes on a release PR, enables auto-merge, and only tags or publishes after that PR has merged to the protected branch.

Why

The prior workflow attempted a direct push to protected main. GitHub rejected the commit after accepting the tag, leaving an unreconciled tag and no published artifacts.

Impact

Release tags now point only to merged protected-branch commits. Required checks and approvals remain enforced; if auto-merge is unavailable, the release PR remains ready for a maintainer instead of bypassing protection.

Validation

  • YAML parsed with Prettier
  • git diff --check

@kayodebristol
kayodebristol marked this pull request as ready for review August 11, 2026 05:34
Copilot AI lite review requested due to automatic review settings August 11, 2026 05:34
@kayodebristol
kayodebristol merged commit b287b26 into main Aug 11, 2026
3 checks passed
@kayodebristol
kayodebristol deleted the codex/protected-release-pipeline branch August 11, 2026 05:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the shared reusable release workflow to work correctly with protected branches by preparing release changes via a PR and only tagging/publishing after that PR has merged, preventing tags from pointing at unmerged commits.

Changes:

  • Adds pull-requests: write permission and a release_commit_exists output to distinguish “prepare PR” runs from “finalize publish” runs.
  • Detects a merged release-preparation commit and skips generating a second bump/changelog when finalizing.
  • Opens a release-preparation PR (attempting auto-merge) and gates tag/release/publish jobs to only run on the post-merge workflow run.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +631 to +642
- name: Open and auto-merge release-preparation PR
if: inputs.dry_run != true && needs.prepare.outputs.release_commit_exists != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION="${{ needs.prepare.outputs.new_version }}"
BRANCH="release/v${VERSION}"
BASE="${{ github.ref_name }}"

git switch -c "$BRANCH"
git push --force-with-lease origin "HEAD:$BRANCH"

Comment on lines +643 to +644
PR_URL=$(gh pr list --repo "${{ github.repository }}" --head "$BRANCH" --base "$BASE" --state open --json url --jq '.[0].url')
if [ -z "$PR_URL" ]; then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants