Add --major-branch flag for GitHub Actions major version refs#27
Merged
Conversation
Opt-in flag that, after a release, creates or hard-resets a major version branch ref (e.g. v1, v2) to the release commit and force-pushes it to the remote. This follows the GitHub Actions convention where consumers pin to a major version ref (e.g. `uses: owner/action@v1`) and automatically receive patch and minor updates without manual ref changes. - New lib/major-branch.js: parses major from tag, runs git branch -f then git push --force origin <major-branch> - --major-branch added to args (both CLIs, typedef, help text) - preview.js shows the flag when enabled (hidden when false)
There was a problem hiding this comment.
Pull request overview
Adds an opt-in --major-branch flag that, after creating a GitHub release, force-updates a major version branch ref (e.g. v1) to the release commit and force-pushes it to origin. This automates the maintenance pattern that GitHub Actions consumers rely on when pinning to owner/action@v1.
Changes:
- New
lib/major-branch.jsmodule exposingmajorBranchName(tag)parser andupdateMajorBranch({tag, commitish, workpath})git driver. - Wires the new flag into
lib/args.js,lib/preview.js, and bothbin/releasearoni.jsandbin/releasearoni-gh.js, running after the release is created and skipped on--dry-run.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| lib/major-branch.js | New module: parse major from tag, then git branch -f + git push --force origin to update the ref. |
| lib/args.js | Adds --major-branch boolean option and typedef entry. |
| lib/preview.js | Adds majorBranch to typedef and hides it from preview output when falsy (matching draft/prerelease). |
| bin/releasearoni.js | Reads argv['major-branch'] into opts and invokes updateMajorBranch after the release/asset upload steps. |
| bin/releasearoni-gh.js | Same wiring as above for the gh CLI variant, invoked after the gh release create/edit block. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Unit tests for majorBranchName covering all tag formats (v-prefixed, unprefixed, multi-digit, edge cases). Integration tests for updateMajorBranch using a local bare repo as the remote, covering branch creation, hard-reset to a newer commit, unparseable tag skip, and un-prefixed tag handling.
Two correctness fixes from review:
- Use git rev-parse <tag>^{commit} to resolve the exact commit SHA from
the tag, rather than passing opts.target_commitish which may be a
branch name and could point to a newer commit if HEAD has moved.
- Switch from git branch -f to git update-ref refs/heads/<branch> so
the major branch can be updated even when it is currently checked out
(git branch -f refuses to move HEAD's branch).
Drop the commitish parameter from updateMajorBranch — the tag is now
the authoritative source. Update integration tests to create git tags
so git rev-parse resolves correctly.
Add the flag to both CLI help blocks and add a dedicated section explaining when to use it, what it does step by step, and how to wire it into package.json scripts.
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.
What
Adds an opt-in
--major-branchflag that, after a successful release, creates or hard-resets a major version branch ref (e.g.v1,v2) to the release commit and force-pushes it to the remote.Why
GitHub Actions consumers typically pin to a major version ref:
This lets them receive patch and minor updates automatically without changing their workflow files. Maintaining that ref manually after every release is error-prone — this flag automates it.
How it works
majorBranchName(tag)parses the major version from any tag format (v1.2.3,1.2.3,v10.0.0→v1,v1,v10)git branch -f <major> <sha>handles both create and hard-reset in one commandgit push --force origin <major>updates the remote refreleasearoniandreleasearoni-ghvariants)--dry-runmajorBranch: truewhen the flag is set (hidden when false, same asdraft/prerelease)Usage
Files changed
lib/major-branch.js— new module with parsing and git logiclib/args.js— new--major-branchoption + typedeflib/preview.js— show flag in preview when enabledbin/releasearoni.js— wire up optbin/releasearoni-gh.js— wire up opt