Skip to content

fix: use semver-based selection for release notes baseline#89

Merged
joshjohanning merged 6 commits into
mainfrom
copilot/fix-release-notes-baseline
Apr 15, 2026
Merged

fix: use semver-based selection for release notes baseline#89
joshjohanning merged 6 commits into
mainfrom
copilot/fix-release-notes-baseline

Conversation

Copilot AI commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

listReleases returns releases sorted by created_at descending, so .find() picks the most recently created release — not the semantically correct predecessor. This causes incorrect release notes in two scenarios:

  1. Hotpatches: v2.0.6 published after v4.0.0 → release notes for v4.0.1 were generated against v2.0.6 instead of v4.0.0
  2. Backports: publishing v2.0.7 when v4.0.1 exists → release notes were generated against v4.0.1 instead of v2.0.6

Changes

  • src/index.js: Replace the previous approach with semver-based selection — fetch all releases, filter to valid semver tags less than the current version, and pick the highest one using semver.lt() and semver.rcompare().
const candidates = releases.data
  .map(r => r.tag_name)
  .filter(tag => tag && semver.valid(tag) && semver.lt(tag, version));

if (candidates.length > 0) {
  candidates.sort(semver.rcompare);
  previousTag = candidates[0];
}
  • __tests__/index.test.js: Reworked release notes tests to cover:
    • Hotpatch scenario (v4.0.1 picks v4.0.0 over chronologically newer v2.0.6)
    • Backport scenario (v2.0.7 picks v2.0.6, not v4.0.1)
    • Non-semver tags are filtered out
    • Fetch failure gracefully falls back to no baseline
  • package.json: Patch bump 3.0.23.0.3

Copilot AI and others added 2 commits April 15, 2026 20:17
…hronological ordering

Fixes bug where hotpatches to older version lines (e.g. v2.0.6 published
after v4.0.0) would be picked as the release notes baseline instead of
the semantically latest release. Uses GitHub's getLatestRelease endpoint
which respects the "latest" designation, with fallback to listReleases.

Agent-Logs-Url: https://github.com/joshjohanning/publish-github-action/sessions/61a91a3a-130d-4656-9ca0-5c9ac14f529a

Co-authored-by: joshjohanning <19912012+joshjohanning@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix release notes baseline to use semantically latest version Fix release notes baseline to use latest release instead of most recently created Apr 15, 2026
Copilot AI requested a review from joshjohanning April 15, 2026 20:21
@joshjohanning joshjohanning marked this pull request as ready for review April 15, 2026 20:30
Copilot AI review requested due to automatic review settings April 15, 2026 20:30
@joshjohanning joshjohanning changed the title Fix release notes baseline to use latest release instead of most recently created fix: release notes baseline to use latest release instead of most recently created Apr 15, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the release-notes baseline selection in this Node.js GitHub Action so that release notes are generated against the semantically “latest” release instead of the most recently created release, which can be incorrect when hotpatches are released on older version lines.

Changes:

  • Switch baseline selection to octokit.rest.repos.getLatestRelease() with a listReleases fallback on API failure.
  • Update Jest tests to mock getLatestRelease, add coverage for fallback behavior and the hotpatch scenario.
  • Bump package version 3.0.2 → 3.0.3 (and sync lockfile), update coverage badge.
Show a summary per file
File Description
src/index.js Uses getLatestRelease to determine the previous tag for release notes; falls back to listReleases on error.
tests/index.test.js Updates mocks and adds tests for getLatestRelease success/failure and hotpatch scenario.
package.json Patch version bump to reflect behavior change.
package-lock.json Syncs lockfile version fields with package.json.
badges/coverage.svg Updates displayed coverage percentage.

Copilot's findings

  • Files reviewed: 3/5 changed files
  • Comments generated: 2

Comment thread src/index.js Outdated
Comment thread src/index.js Outdated
Address review feedback:
- Restructure so listReleases fallback runs whenever previousTag is
  unset (not only when getLatestRelease throws)
- Update catch comment to reflect all failure modes, not just first release
- Add test for non-semver latest release tag falling back to listReleases

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the action’s release-notes baseline selection to use GitHub’s “latest release” designation (instead of relying on release creation order), improving correctness when hotpatches are published on older version lines.

Changes:

  • Use repos.getLatestRelease() to determine the previous tag for release notes, with a listReleases fallback.
  • Update/add Jest tests to cover the new “latest” behavior, fallback behavior, and hotpatch scenario.
  • Bump package version to 3.0.3 and update the coverage badge.
Show a summary per file
File Description
src/index.js Switches baseline selection to getLatestRelease() with fallback logic.
__tests__/index.test.js Updates mocks and adds tests for latest-release behavior + fallbacks.
package.json Patch version bump to reflect behavior change.
package-lock.json Synces lockfile version field with package version bump.
badges/coverage.svg Updates coverage badge to new percentage.

Copilot's findings

  • Files reviewed: 3/5 changed files
  • Comments generated: 1

Comment thread src/index.js Outdated
Replace getLatestRelease API with semver comparison to find the highest
released version less than the current version. This correctly handles
both hotpatches (v2.0.6 published after v4.0.0) and backports (publishing
v2.0.7 when v4.0.1 exists).

- Use semver.valid/lt/rcompare to filter and sort release tags
- Remove getLatestRelease dependency entirely
- Add backport scenario test (v2.0.7 when v4.0.1 exists → picks v2.0.6)
- Add non-semver tag filtering test
@joshjohanning joshjohanning changed the title fix: release notes baseline to use latest release instead of most recently created fix: use semver-based selection for release notes baseline Apr 15, 2026
@joshjohanning joshjohanning requested a review from Copilot April 15, 2026 20:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes release-notes baseline selection to use semantic version ordering instead of relying on the GitHub Releases API’s created_at sort order, preventing incorrect baselines in hotpatch/backport scenarios.

Changes:

  • Update previous-release selection to filter valid semver tags < current and choose the highest via semver.rcompare.
  • Expand Jest coverage for hotpatch/backport and non-semver-tag scenarios.
  • Bump package version to 3.0.3 and refresh coverage badge.
Show a summary per file
File Description
src/index.js Switch baseline selection logic to semver-based filtering/sorting.
__tests__/index.test.js Add/adjust tests to validate semver-based baseline selection behavior.
package.json Patch version bump 3.0.23.0.3.
package-lock.json Lockfile version bump to match package.json.
badges/coverage.svg Update coverage badge value.

Copilot's findings

  • Files reviewed: 3/5 changed files
  • Comments generated: 2

Comment thread src/index.js Outdated
Comment thread __tests__/index.test.js Outdated
- Use octokit.paginate() to fetch all releases instead of per_page: 100
- Use real semver valid/lt/rcompare in test mocks instead of simplified
  re-implementations, only mock major/minor which need controlled values
@joshjohanning joshjohanning merged commit b135774 into main Apr 15, 2026
4 checks passed
@joshjohanning joshjohanning deleted the copilot/fix-release-notes-baseline branch April 15, 2026 21:09
@github-actions

Copy link
Copy Markdown

📦 Draft Release Created

A draft release v3.0.3 has been created for this PR.

🔗 View Draft Release

Next Steps

  • Review the release notes
  • Publish the release to make it permanent

This is an automated reminder from the publish-github-action workflow.

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.

Bug: Release notes baseline picks chronologically newest release instead of semantically latest version

3 participants