Skip to content

Improve release script#2278

Merged
r0b1n merged 2 commits into
mainfrom
chore/improve-release-script
Jun 19, 2026
Merged

Improve release script#2278
r0b1n merged 2 commits into
mainfrom
chore/improve-release-script

Conversation

@r0b1n

@r0b1n r0b1n commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator
  • Print changelogs
  • Make sure release uses main

@r0b1n r0b1n requested a review from a team as a code owner June 18, 2026 15:25
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
automation/utils/bin/rui-prepare-release.ts Adds ensureMainBranch() call before Jira init
automation/utils/src/prepare-release-helpers.ts Adds ensureMainBranch(), printUnreleasedChangelog(), and box-drawing helpers

Skipped (out of scope): dist/, pnpm-lock.yaml

CI checks could not be fetched automatically (permission prompt in this environment); verify they are green before merging.


Findings

⚠️ Low — git checkout main with piped stdio swallows git's error message

File: automation/utils/src/prepare-release-helpers.ts line 155
Problem: { stdio: "pipe" } silences git's output. If the working tree is dirty when switchToMain() runs, git prints a helpful "error: Your local changes would be overwritten by checkout" to stderr — but with piped stdio that message is swallowed and the outer catch in main() will show only a raw exception, leaving the user to guess what happened.
Fix: Either use stdio: "inherit" for this one call so git can speak for itself, or proactively check for a dirty tree before attempting checkout:

const { stdout: status } = await exec("git status --porcelain", { stdio: "pipe" });
if (status.trim()) {
    console.log(chalk.red("❌ Working tree has uncommitted changes. Stash or commit before switching."));
    process.exit(1);
}
await exec("git checkout main", { stdio: "inherit" });

⚠️ Low — content[0] accessed without a guard

File: automation/utils/src/prepare-release-helpers.ts line 302
Problem: printUnreleasedChangelog always accesses changelog.changelog.content[0] without checking that content is non-empty. The call sites guard with hasUnreleasedLogs(), but the implicit assumption that content[0] is the unreleased entry is fragile — if the contract ever diverges (empty file, unexpected structure), this silently throws.
Fix: Add a defensive early return:

const unreleased = changelog.changelog.content[0];
if (!unreleased) return;

⚠️ Low — padEnd in box renderer uses raw string length, not visible length

File: automation/utils/src/prepare-release-helpers.ts line 292
Problem: wrappedLine.padEnd(contentWidth) measures the raw string length. Today changelog entries are plain text so this is fine, but visibleLen is already defined in this file — using it here would make printSectionBox robust to any future ANSI-coloured log entries without silent misalignment.
Note: Not blocking; changelog entries are plain text today.
Fix:

const pad = contentWidth - visibleLen(wrappedLine);
console.log(`${treePrefix}${chalk.dim("│")} ${wrappedLine}${" ".repeat(Math.max(0, pad))} ${chalk.dim("│")}`);

Positives

  • All four sync states (up-to-date, behind, ahead, diverged) are handled explicitly with appropriate user prompts — no silent assumptions.
  • getRemoteSyncCounts runs the two rev-list commands in parallel with Promise.all, a nice performance detail.
  • printSectionBox respects terminal width via process.stdout.columns with a sensible fallback of 100.
  • The no-control-regex eslint suppression is correctly scoped to the one line that needs it.
  • fastForwardMain uses --ff-only rather than a plain merge, which correctly refuses if history has diverged.

@r0b1n r0b1n merged commit 07eb1c8 into main Jun 19, 2026
20 of 22 checks passed
@r0b1n r0b1n deleted the chore/improve-release-script branch June 19, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants