Skip to content

Add --major-branch flag for GitHub Actions major version refs#27

Merged
bcomnes merged 4 commits into
masterfrom
feature/major-version-branches
May 18, 2026
Merged

Add --major-branch flag for GitHub Actions major version refs#27
bcomnes merged 4 commits into
masterfrom
feature/major-version-branches

Conversation

@bcomnes

@bcomnes bcomnes commented May 18, 2026

Copy link
Copy Markdown
Owner

What

Adds an opt-in --major-branch flag 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:

uses: owner/action@v1

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.0v1, v1, v10)
  • git branch -f <major> <sha> handles both create and hard-reset in one command
  • git push --force origin <major> updates the remote ref
  • Runs after the GitHub release is created (both releasearoni and releasearoni-gh variants)
  • Skipped entirely on --dry-run
  • Preview output shows majorBranch: true when the flag is set (hidden when false, same as draft/prerelease)

Usage

releasearoni --major-branch
releasearoni-gh --major-branch

Files changed

  • lib/major-branch.js — new module with parsing and git logic
  • lib/args.js — new --major-branch option + typedef
  • lib/preview.js — show flag in preview when enabled
  • bin/releasearoni.js — wire up opt
  • bin/releasearoni-gh.js — wire up opt

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)
Copilot AI review requested due to automatic review settings May 18, 2026 04:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.js module exposing majorBranchName(tag) parser and updateMajorBranch({tag, commitish, workpath}) git driver.
  • Wires the new flag into lib/args.js, lib/preview.js, and both bin/releasearoni.js and bin/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.

Comment thread lib/major-branch.js
Comment thread lib/major-branch.js Outdated
Comment thread lib/major-branch.js Outdated
bcomnes added 2 commits May 17, 2026 21:24
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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 7 changed files in this pull request and generated no new comments.

@bcomnes bcomnes merged commit 858d708 into master May 18, 2026
4 checks passed
@bcomnes bcomnes deleted the feature/major-version-branches branch May 18, 2026 04:30
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