Skip to content

fix: Correct calculation of commits for changelog for release workflows#1971

Merged
morri-son merged 5 commits into
open-component-model:mainfrom
morri-son:fix-changelog-in-git-cliff
Mar 19, 2026
Merged

fix: Correct calculation of commits for changelog for release workflows#1971
morri-son merged 5 commits into
open-component-model:mainfrom
morri-son:fix-changelog-in-git-cliff

Conversation

@morri-son

@morri-son morri-son commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

On-behalf-of: Gerald Morrison (SAP) gerald.morrison@sap.com

What this PR does / why we need it

Add new function to calculate the latest previous non-RC tag to determine the correct range of commits for the changelog.

Summary by CodeRabbit

  • Chores
    • Improved release versioning to compute and expose the previous release tag and a concrete changelog range for release-candidate flows, pass that range into the changelog generator, and surface these values in step summaries and workflow outputs (first-release behavior preserved).
  • Tests
    • Added comprehensive tests covering prior-release detection, RC and edge-case scenarios to ensure correct changelog-range behavior.

…mine the correct range of commits for the changelog.

On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
@morri-son morri-son requested a review from a team as a code owner March 13, 2026 15:33
@github-actions github-actions Bot added component/github-actions Changes on GitHub Actions or within `.github/` directory size/m Medium labels Mar 13, 2026
@coderabbitai

coderabbitai Bot commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 57899fc9-7b21-4f71-b1e4-dfb4879044f5

📥 Commits

Reviewing files that changed from the base of the PR and between 2029d54 and 3255551.

📒 Files selected for processing (2)
  • .github/scripts/release-versioning.js
  • .github/scripts/release-versioning.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/release-versioning.test.js

📝 Walkthrough

Walkthrough

Computes the previous non-RC release tag, derives a changelog range, exports it from the release-versioning script, adds tests for the helper, and threads the changelog_range through the release-candidate workflow into git-cliff.

Changes

Cohort / File(s) Summary
Changelog range logic
.github/scripts/release-versioning.js
Adds and exports findPreviousTag(tags, newTag); computes previousTag and changelogRange, logs them, exposes changelog_range output and step-summary entries.
Tests
.github/scripts/release-versioning.test.js
Adds comprehensive tests for findPreviousTag() covering normal, first-release, RC-only, excluding new tag, semantic ordering, non-semver, and numeric-sorting scenarios.
Workflow integration
.github/workflows/release-candidate-version.yml
Adds changelog_range input/output, wires prepare job output into CHANGELOG_RANGE env, and conditions git-cliff invocation to use the provided range or fall back to --latest.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Workflow as Release Workflow
participant Script as release-versioning.js
participant Git as Git (tags)
participant GitCliff as git-cliff

Workflow->>Script: run prepare job
Script->>Git: list tags
Git-->>Script: tags list
Script->>Script: findPreviousTag(tags, newTag) -> previousTag, changelogRange
Script-->>Workflow: set output changelog_range
Workflow->>GitCliff: invoke with CHANGELOG_RANGE (or --latest)
GitCliff->>Git: generate changelog for range

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested labels

kind/chore

Suggested reviewers

  • matthiasbruns
  • jakobmoellerdev

Poem

🐇 I hopped through tags both near and far,
Skipped the RCs and found the star,
Poked git‑cliff with a tidy range,
Changelogs tidy, neat, and strange —
Carrots for releases, hip hooray! 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding logic to correct changelog commit range calculation by finding the previous non-RC tag for release workflows.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

matthiasbruns
matthiasbruns previously approved these changes Mar 16, 2026
Comment thread .github/scripts/release-versioning.test.js

@piotrjanik piotrjanik 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.

LGTM, one corner case to check

On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
@morri-son

Copy link
Copy Markdown
Contributor Author

@piotrjanik

LGTM, one corner case to check

I added a semver check and a test for your mentioned case.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/scripts/release-versioning.js:
- Around line 256-267: findPreviousTag currently picks the highest stable tag
without ensuring it is older than newTag; update findPreviousTag to first parse
newTag via parseVersion and filter tags to only those stable tags whose semantic
version is strictly less than newTag's version (compare major, minor, patch
arrays element-wise using parseVersion results) before sorting and returning the
top candidate; reference parseVersion, newTag, and findPreviousTag in your
change so the comparison logic ensures returned tag is actually previous to
newTag.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9a67ed05-6dba-494b-8374-d59d2953a2f8

📥 Commits

Reviewing files that changed from the base of the PR and between e8e6452 and 2029d54.

📒 Files selected for processing (2)
  • .github/scripts/release-versioning.js
  • .github/scripts/release-versioning.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/scripts/release-versioning.test.js

Comment thread .github/scripts/release-versioning.js Outdated
…t-cliff

On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
@morri-son

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@morri-son morri-son enabled auto-merge (squash) March 18, 2026 10:43
Comment thread .github/scripts/release-versioning.js
@matthiasbruns

Copy link
Copy Markdown
Contributor

just a nit - while checking your tests I was confused that RCs are not included. While the docs way "...stable semver..." I only made the connection after reading it again.

@matthiasbruns matthiasbruns 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.

ignore my nit - I do not want to block because of nits

@morri-son morri-son merged commit 7842164 into open-component-model:main Mar 19, 2026
16 checks passed
frewilhelm pushed a commit to frewilhelm/open-component-model that referenced this pull request Mar 19, 2026
…ws (open-component-model#1971)

On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com>

<!-- markdownlint-disable MD041 -->
#### What this PR does / why we need it
Add new function to calculate the latest previous non-RC tag to
determine the correct range of commits for the changelog.
  

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Improved release versioning to compute and expose the previous release
tag and a concrete changelog range for release-candidate flows, pass
that range into the changelog generator, and surface these values in
step summaries and workflow outputs (first-release behavior preserved).
* **Tests**
* Added comprehensive tests covering prior-release detection, RC and
edge-case scenarios to ensure correct changelog-range behavior.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
Co-authored-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
@coderabbitai coderabbitai Bot mentioned this pull request Apr 8, 2026
@morri-son morri-son deleted the fix-changelog-in-git-cliff branch April 23, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component/github-actions Changes on GitHub Actions or within `.github/` directory kind/bugfix Bug size/m Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants