Skip to content

Bootstrap protected release branches through the API - #32

Merged
kayodebristol merged 1 commit into
mainfrom
codex/release-branch-bootstrap
Aug 11, 2026
Merged

Bootstrap protected release branches through the API#32
kayodebristol merged 1 commit into
mainfrom
codex/release-branch-bootstrap

Conversation

@kayodebristol

Copy link
Copy Markdown
Contributor

What changed

Creates a release branch at the current protected base through the GitHub refs API before pushing the generated version/changelog commit.

Why

The first protected-release run could not push a new branch because its history contained a workflow-file change. GitHub Actions rejected that push without a workflow permission, even though the generated release commit does not edit workflows.

Impact

The release preparation PR can now be created without bypassing branch protection or granting a workflow token broader workflow-edit authority.

Validation

  • Failure reproduced from run 31462102269
  • YAML parsed with Prettier
  • git diff --check

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

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

This PR updates the reusable release workflow to bootstrap protected release/v* branches via the GitHub Refs API before pushing the generated version/changelog commit, avoiding GitHub Actions’ restrictions when a brand-new branch history first introduces workflow files.

Changes:

  • Record the protected base commit SHA early in the release job for later branch creation.
  • Create refs/heads/release/v{VERSION} via gh api before pushing the release-preparation commit.
  • Keep the existing release-preparation PR creation/auto-merge flow, but make branch creation compatible with protected bases.

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

Comment on lines +652 to +656
if ! git ls-remote --exit-code --heads origin "$BRANCH" >/dev/null 2>&1; then
gh api --method POST "repos/${{ github.repository }}/git/refs" \
-f "ref=refs/heads/$BRANCH" \
-f "sha=${{ steps.release_base.outputs.sha }}"
fi
Comment on lines 658 to 660
git switch -c "$BRANCH"
git push --force-with-lease origin "HEAD:$BRANCH"

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