Skip to content

chore: refuse release.sh from main; require release branch#62

Merged
Jamkris merged 1 commit into
mainfrom
chore/release-guard
May 12, 2026
Merged

chore: refuse release.sh from main; require release branch#62
Jamkris merged 1 commit into
mainfrom
chore/release-guard

Conversation

@Jamkris
Copy link
Copy Markdown
Owner

@Jamkris Jamkris commented May 12, 2026

Summary

`scripts/release.sh` used to run on any branch and only print a hint about creating a PR when not on `main`. Running it from `main` accidentally commits a version bump directly to `main`, bypassing PR review, CI, and the merge audit trail. This happened today — two stray local commits had to be reset.

This PR adds an explicit guard: if HEAD is on `main`, the script prints the proper 5-step workflow and exits 1 before touching any file. No env-var escape hatch — normalising the wrong path is what caused the incident in the first place.

Behaviour

Before: running on main silently committed the version bump to main; a footer suggested a PR but the bump was already on the wrong branch.

After:

```
$ git checkout main
$ ./scripts/release.sh 1.3.9
Error: refusing to run release from 'main' branch.

Version bumps must go through a PR:

  1. git checkout -b chore/release-v1.3.9
  2. ./scripts/release.sh 1.3.9 # re-run on the release branch
  3. git push -u origin chore/release-v1.3.9
  4. gh pr create --title "chore: release v1.3.9" --body "Bump version to 1.3.9"
  5. Merge once CI is green, then push the tag.
    ```

On any non-main branch, the script proceeds normally.

Also in this PR

  • Dropped the dead `if [ "$BRANCH" != "main" ]` footer branch — `BRANCH = main` is now unreachable past the guard, so collapsed the "Next steps" to the single correct path.

Test plan

  • `npm run lint` — clean
  • `npm test` — 264/264
  • Dry-run on `chore/release-guard` branch — script proceeds past the guard (made a throwaway 9.9.9 commit, rolled back)
  • Dry-run on `main` — script prints the 5-step workflow and exits 1; `package.json` / `gemini-extension.json` / `plugin.json` are not modified

Follow-up (after this merges)

Re-do the 1.3.9 release the proper way:

  1. `git checkout main && git pull`
  2. `git checkout -b chore/release-v1.3.9`
  3. `./scripts/release.sh 1.3.9`
  4. Push the branch, open the release PR, merge, push the tag.

Summary by cubic

Add a hard guard in scripts/release.sh to refuse running on main, forcing releases to go through a release branch and PR. This prevents accidental version bumps on main and ensures CI and review run every time.

  • Refactors
    • Detect main, print a 5-step release workflow, and exit 1 before touching files.
    • Remove the dead if [ "$BRANCH" != "main" ] branch and simplify “Next steps” to the single PR path (push branch, open PR, push tag after merge).

Written for commit 468bf4f. Summary will update on new commits.

scripts/release.sh used to run on any branch and only hinted "create
a PR" when not on main. Running it directly on main accidentally
commits a version bump to main without going through PR review, CI,
or the merge audit trail — discovered the hard way today (two stray
local commits had to be reset).

This change adds an explicit guard at the top of the script: if the
current branch is `main`, print the proper workflow and exit 1
before touching any file. No env-var escape hatch — normalising the
wrong path is what got us here in the first place. For a genuine
emergency the user can comment out the guard locally.

Also tightens the "Next steps" footer to the single (and now only)
correct path — create a release branch, push, PR, merge, push tag.
Drops the dead `if BRANCH != main` branch since `BRANCH = main` is
now unreachable.

Verified by dry-run:
- on chore/release-guard: script proceeds past the guard.
- on main: script prints the 5-step workflow and exits 1 without
  modifying package.json / gemini-extension.json / plugin.json.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Important

Review skipped

Ignore keyword(s) in the title.

⛔ Ignored keywords (3)
  • bump version
  • release
  • chore: bump

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5be30a41-124f-4000-b953-4039ab154eb8

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/release-guard

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.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-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.

No issues found across 1 file

@Jamkris Jamkris merged commit e17ea83 into main May 12, 2026
10 checks passed
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.

1 participant