Skip to content

fix(automation): skip changelog PR when version already stamped#2327

Closed
rahmanunver wants to merge 1 commit into
mainfrom
fix/create-gh-release-pre-stamped-changelog
Closed

fix(automation): skip changelog PR when version already stamped#2327
rahmanunver wants to merge 1 commit into
mainfrom
fix/create-gh-release-pre-stamped-changelog

Conversation

@rahmanunver

Copy link
Copy Markdown
Contributor

No description provided.

@rahmanunver rahmanunver requested a review from a team as a code owner July 14, 2026 15:07
@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-create-gh-release.ts Added fast-path: if version already stamped in CHANGELOG.md, skip changelog PR and write release notes directly

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

CI checks still in progress at review time; Snyk license/security checks are ERROR (pre-existing, unrelated to this change).


Findings

⚠️ Low — getLatestReleaseContent() always returns content[1], not necessarily pkg.version

File: automation/utils/bin/rui-create-gh-release.ts line 79
Note: hasVersion(pkg.version) scans the entire content array, so it returns true even if pkg.version is at index 2, 3, etc. (i.e., an older stamped entry). getLatestReleaseContent() unconditionally returns content[1] — the most recent stamped entry — regardless of which version matched. If a CHANGELOG has two stamped entries and pkg.version is the older one, the wrong release notes get written.

In practice this is unlikely (a release script runs against the current version, which should always be the latest entry), but the code silently produces incorrect output rather than throwing. A defensive guard would make the intent explicit:

const content = changelog.getLatestReleaseContent();
// Optional guard — belt-and-suspenders
const latestVersion = changelog.changelog.content[1];
if ("version" in latestVersion && !latestVersion.version.equals(pkg.version)) {
    throw new Error(
        `Version mismatch: expected ${version} at top of CHANGELOG but found ${latestVersion.version.format()}`
    );
}
await writeFile(notesFile, content);

Or, if WidgetChangelogFileWrapper exposes a method to get content for a specific version, use that instead.


Positives

  • The early-exit check (changelog.hasVersion(pkg.version)) directly reuses the existing WidgetChangelogFileWrapper API rather than duplicating parsing logic — clean integration.
  • Both branches of the new if/else preserve the existing process.env.RELEASE_NOTES_FILE = notesFile assignment, keeping the downstream createGithubReleaseFrom call unchanged.
  • The comment above the new block (// If the version is already stamped...) explains the non-obvious scenario that motivated this change.

@rahmanunver rahmanunver deleted the fix/create-gh-release-pre-stamped-changelog branch July 14, 2026 15:17
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.

1 participant