Skip to content

Conversation

@msanatan
Copy link
Member

@msanatan msanatan commented Jan 23, 2026

Description

We now create releases after merging beta branch to main.

Type of Change

  • Refactoring (no functional changes)

Changes Made

Adjust CI because we now merge to beta instead of main

Testing/Screenshots/Recordings

N/A

Documentation Updates

  • I have added/removed/modified tools or resources
  • If yes, I have updated all documentation files using:
    • The LLM prompt at tools/UPDATE_DOCS_PROMPT.md (recommended)
    • Manual updates following the guide at tools/UPDATE_DOCS.md

Added releasing guidelines

Related Issues

N/A

Additional Notes

N/A

Summary by Sourcery

Update the release workflow to bump versions and tag releases from main via temporary PRs, then automatically sync main back into beta, and document the new releasing process.

CI:

  • Revise the release GitHub Actions workflow to enforce running on main, perform version bumps through temporary release branches and PRs, create tags only after merges, clean up release branches, and automatically sync main into beta via PR with auto-merge.

Documentation:

  • Add maintainer-facing releasing guide describing the beta→main promotion flow, manual release workflow, required repo settings, and failure recovery steps.

Summary by CodeRabbit

  • Chores

    • Enhanced release automation pipeline with improved workflow reliability and version management.
  • Documentation

    • Added comprehensive guide for maintainers detailing the release process, including promotion workflow, repository settings, and troubleshooting steps.

✏️ Tip: You can customize this high-level summary in your review settings.

Add safeguards to prevent concurrent releases and ensure beta stays in sync:
- Add concurrency group to prevent overlapping release runs
- Enforce workflow runs only on main branch (fail if run elsewhere)
- Explicitly checkout and push to main (not dynamic branch)
- Fail if release tag already exists (was silently skipping)
- Add sync_beta job that merges main back into beta after release
- Add docs/guides/RELEASING.md with two
For release notes to work we need for PRs from beta to main to not be squashed. We also want to enforce all changes to be via PRs, for humans. But that also limits GH Actions.

An alternative is creating a GH App with bypass permissions but that felt like overkill

Replace direct pushes to main/beta with PR-based workflow for better branch protection compatibility:
- Create temporary release/vX.Y.Z branch for version bump
- Open PR from release branch into main, enable auto-merge
- Poll for PR merge completion (up to 2 minutes) before creating tag
- Fetch merged main and create tag on merged commit
- Clean up release branch after tag creation
- Create PR to merge main into beta (skip if already
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Restructures the release workflow to implement PR-based version bumping with a temporary release branch, adds a beta sync job to merge main back to beta, and introduces GitHub release creation automation with auto-merge support for bump PRs. Includes comprehensive release documentation for maintainers.

Changes

Cohort / File(s) Summary
Release Workflow Refactor
\.github/workflows/release.yml
Adds workflow concurrency, enforces main branch execution, commits version bumps to temporary release/v<version> branch, creates and auto-merges version bump PR, implements tag creation after merge completion with re-tagging guard, adds new sync_beta job to merge main back to beta via PR, includes cleanup of release branch, and integrates GitHub release creation flow.
Release Documentation
docs/guides/RELEASING.md
Introduces comprehensive maintainer guide covering two-branch flow (beta/main), release checklist, workflow steps with polling/merge confirmation, required repository settings (branch protection, auto-merge), and failure recovery procedures.

Sequence Diagram

sequenceDiagram
    actor User
    participant GitHub as GitHub<br/>(Workflow)
    participant Git as Git Repo
    participant PR as PR System
    participant Release as Release Job

    User->>GitHub: Trigger release workflow on main
    GitHub->>Git: Checkout main branch
    GitHub->>Git: Commit version bump to release/v* branch
    GitHub->>Git: Push release branch
    GitHub->>PR: Create version bump PR (release/* → main)
    GitHub->>PR: Enable auto-merge on PR
    PR->>PR: Poll PR merge status
    PR->>Git: Merge bump PR into main
    GitHub->>Git: Fetch merged main
    GitHub->>Git: Create & push version tag
    Release->>GitHub: Create GitHub Release
    GitHub->>PR: Create sync PR (main → beta)
    PR->>Git: Merge sync PR if not up-to-date
    GitHub->>Git: Delete release branch cleanup
    GitHub->>User: Release complete
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • CI Updates #536: Modifies .github/workflows/release.yml with overlapping release pipeline changes including tag creation, job restructuring, and post-release publishing steps.
  • Marcus/update readme on release #607: Modifies .github/workflows/release.yml's release flow with commit/version-update steps that include additional file handling for README updates.

Poem

🐰 A rabbit hops through branches with glee,
Automating releases, one PR to three,
Version bumps merge, tags bloom and shine,
Beta syncs back—the workflow's divine!
Maintenance made merry, as smooth as can be! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: updating the CI flow to bump versions from beta to main and sync back, which matches the core objectives of the PR.
Description check ✅ Passed The description covers key sections including Type of Change and Changes Made, though it lacks specific details about what CI adjustments were made and how the release process changed.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@msanatan msanatan changed the base branch from beta to main January 23, 2026 01:32
@msanatan msanatan changed the base branch from main to beta January 23, 2026 01:34
@msanatan
Copy link
Member Author

@dsarno @Scriptwonder - I'll merge this to main now so our CI should work in the next release.

New flow since we now merge to beta by default:

  • PR from beta to main when we're
  • Run workflow on main
    • Workflow creates PR to bump version that auto merges
    • Workflow creates PR back to beta (so it gets the version bump) that auto merges

It could be simpler but branch rules also limit with GitHub actions can do

@msanatan msanatan merged commit f314a23 into beta Jan 23, 2026
1 check passed
@msanatan msanatan deleted the update-ci branch January 23, 2026 01:36
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 23, 2026

Reviewer's Guide

Refactors the release GitHub Actions workflow to run only from main, create a temporary release branch and PR for version bumps, tag and release from the merged main commit, then sync main back into beta via PR, and documents the new two-branch release process for maintainers.

Sequence diagram for new release workflow from main with beta sync

sequenceDiagram
  actor Maintainer
  participant ActionsRelease as Actions_release_workflow
  participant JobBump as Job_bump
  participant JobSync as Job_sync_beta
  participant Main as Branch_main
  participant Beta as Branch_beta
  participant RelBranch as Branch_release_vX_Y_Z
  participant BumpPR as PR_release_vX_Y_Z_to_main
  participant SyncPR as PR_main_to_beta
  participant Tags as Git_tags
  participant GHRelease as GitHub_Release

  Maintainer->>ActionsRelease: Run workflow on main with bump_type
  ActionsRelease->>JobBump: Start bump job

  JobBump->>JobBump: Ensure ref is main
  JobBump->>Main: Checkout main
  JobBump->>JobBump: Compute new_version and tag

  JobBump->>RelBranch: Create branch release_vX_Y_Z from main
  JobBump->>RelBranch: Commit version bump
  JobBump->>RelBranch: Push release_vX_Y_Z to origin

  JobBump->>BumpPR: Create PR base main head release_vX_Y_Z
  JobBump->>BumpPR: Enable auto-merge and wait for merge
  BumpPR->>Main: Merge release_vX_Y_Z into main

  JobBump->>Main: Fetch and pull merged main
  JobBump->>Tags: Create annotated tag vX_Y_Z on main commit
  JobBump->>Tags: Push tag to origin

  JobBump->>GHRelease: Create GitHub Release for tag
  JobBump->>RelBranch: Delete release_vX_Y_Z branch on origin

  ActionsRelease->>JobSync: Start sync_beta job (needs bump)

  JobSync->>Main: Checkout main
  JobSync->>Beta: Fetch beta
  JobSync->>JobSync: Check if beta is behind main
  alt beta already up to date
    JobSync-->>ActionsRelease: Skip sync PR
  else beta behind main
    JobSync->>SyncPR: Create PR base beta head main
    JobSync->>SyncPR: Enable auto-merge and wait for merge
    SyncPR->>Beta: Merge main into beta
  end
Loading

Flow diagram for sync_beta job logic

flowchart TD
  A["Start sync_beta job"] --> B["Checkout main"]
  B --> C["Fetch origin/beta"]
  C --> D["Is origin/main ancestor of origin/beta?"]

  D -->|yes| E["beta already up to date"]
  E --> F["Set skipped output to true"]
  F --> G["End job"]

  D -->|no| H["Create PR base beta head main"]
  H --> I["Store PR url and number outputs"]
  I --> J["Enable auto-merge for PR"]
  J --> K["Poll PR state up to 2 minutes"]
  K --> L{PR merged?}

  L -->|yes| M["Sync PR merged successfully"]
  M --> G

  L -->|no| N["Attempt direct merge of PR"]
  N --> O["End job"]
Loading

File-Level Changes

Change Details Files
Restructure version bump flow to use a temporary release branch merged into main via PR instead of committing directly to the triggering branch.
  • Ensure the release workflow only runs on the main branch and explicitly checks out main.
  • Compute the new version and update versioned files as before using the existing scripts.
  • Create a temporary release/vX.Y.Z branch for the version bump commit instead of committing on the current ref.
  • Push the temporary release branch to origin and expose its name as a job output.
.github/workflows/release.yml
Automate PR-based merging, tagging, and cleanup in the release workflow.
  • Create a PR from the temporary release branch into main using the GitHub CLI and capture its URL and number.
  • Enable auto-merge on the bump PR, poll for merge completion, and fall back to a direct merge if auto-merge does not complete in time.
  • After the PR merges, fetch and checkout updated main, verify the tag does not already exist, then create and push an annotated tag for the new version.
  • Always attempt to delete the temporary release branch on origin at the end of the bump job to avoid leftover branches.
.github/workflows/release.yml
Add an automated sync from main back into beta after a release.
  • Introduce a new sync_beta job that depends on the bump job.
  • Check if beta is behind main; if not, skip the sync with an explicit output flag.
  • When beta is behind, create a PR merging main into beta using the GitHub CLI and capture its PR number.
  • Enable auto-merge on the sync PR, poll for merge completion, and fall back to a direct merge if needed.
.github/workflows/release.yml
Harden the release workflow and permissions for reliability and safety.
  • Add workflow-level concurrency configuration to serialize release runs and avoid overlapping releases.
  • Expand permissions to include pull-requests: write where needed for PR creation and merging.
  • Change tag-exists behavior to fail the workflow if the tag already exists instead of silently skipping tag creation.
.github/workflows/release.yml
Document the new two-branch release process and required GitHub settings for maintainers.
  • Describe the beta (integration) and main (stable) branch roles and the promotion flow from beta to main.
  • Document the manual Release workflow trigger, including bump type selection and what the workflow does step-by-step.
  • Specify recommended branch protection and auto-merge settings for main and beta to work with the automated flow.
  • Outline common failure modes (existing tags, failed bump/sync PRs, leftover release branches) and how to recover from them.
docs/guides/RELEASING.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The logic for enabling auto-merge and polling for PR merge completion is duplicated between the bump and sync jobs; consider extracting this into a shared script or composite action to reduce duplication and keep future changes in one place.
  • In the sync_beta job, gh pr create will fail if a main -> beta PR already exists; it may be more robust to first check for an existing open PR between these branches and reuse/annotate it instead of unconditionally creating a new one.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The logic for enabling auto-merge and polling for PR merge completion is duplicated between the bump and sync jobs; consider extracting this into a shared script or composite action to reduce duplication and keep future changes in one place.
- In the `sync_beta` job, `gh pr create` will fail if a `main -> beta` PR already exists; it may be more robust to first check for an existing open PR between these branches and reuse/annotate it instead of unconditionally creating a new one.

## Individual Comments

### Comment 1
<location> `.github/workflows/release.yml:180-188` </location>
<code_context>
           git tag -a "$TAG" -m "Version ${TAG#v}"
           git push origin "$TAG"

+      - name: Clean up release branch
+        if: always()
+        env:
+          GH_TOKEN: ${{ github.token }}
+          BRANCH: ${{ steps.bump_branch.outputs.name }}
+        shell: bash
+        run: |
+          set -euo pipefail
+          git push origin --delete "$BRANCH" || true
+
       - name: Create GitHub release
</code_context>

<issue_to_address>
**issue (bug_risk):** The release branch is deleted unconditionally, even if the bump PR fails to merge.

Because this step uses `if: always()`, it deletes the remote release branch even when `gh pr merge` fails (e.g., due to reviews, checks, or branch protection). That leaves an open PR whose source branch has been deleted, making recovery manual and error-prone.

Please gate this cleanup on the PR actually being merged (or otherwise in a terminal state), e.g. by checking `gh pr view` or wiring this step to depend on the merge step’s outcome/output before deleting the branch.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +180 to +188
- name: Clean up release branch
if: always()
env:
GH_TOKEN: ${{ github.token }}
BRANCH: ${{ steps.bump_branch.outputs.name }}
shell: bash
run: |
set -euo pipefail
git push origin --delete "$BRANCH" || true
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (bug_risk): The release branch is deleted unconditionally, even if the bump PR fails to merge.

Because this step uses if: always(), it deletes the remote release branch even when gh pr merge fails (e.g., due to reviews, checks, or branch protection). That leaves an open PR whose source branch has been deleted, making recovery manual and error-prone.

Please gate this cleanup on the PR actually being merged (or otherwise in a terminal state), e.g. by checking gh pr view or wiring this step to depend on the merge step’s outcome/output before deleting the 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