Skip to content

Commit

Permalink
add dummy entry to release-notes script for new pkg
Browse files Browse the repository at this point in the history
The regex checks for existence of the previous h2
but new packages will not have versions before it.
Add a dummy h2 to satisfy the regex with minimal
overall changes.
To test this, replace Unreleased in the CHANGELOG
to an actual version, like 1.1.1.
Then run the script as described in the comments.
There should be a .tmp/release-notes.md with
the contents of the changelog for that version.
  • Loading branch information
JamieDanielson committed Aug 15, 2024
1 parent a079e5c commit d3b84f6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions scripts/extract-latest-release-notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* - node scripts/extract-latest-release-notes.js [PATH TO CHANGELOG]...
* Examples:
* - node scripts/extract-latest-release-notes.js ./packages/CHANGELOG.md
* - node scripts/extract-latest-release-notes.js ./packages/opentelemetry-semantic-conventions/CHANGELOG.md
* - node scripts/extract-latest-release-notes.js ./experimental/CHANGELOG.md
* - node scripts/extract-latest-release-notes.js ./api/CHANGELOG.md ./packages/CHANGELOG.md ./experimental/CHANGELOG.md
*/
Expand All @@ -17,8 +18,8 @@ function extractLatestChangelog(changelogPath) {
// Matches everything from the first entry at h2 ('##') followed by a space and a non-prerelease semver version
// until the next entry at h2.
const firstReleaseNoteEntryExp = /^## \d+\.\d+\.\d\n.*?(?=^## )/ms;

return changelog.match(firstReleaseNoteEntryExp)[0];
// append the changelog with a dummy entry to ensure new packages match the regex
return (changelog + '\n## ').match(firstReleaseNoteEntryExp)[0];
}

fs.mkdirSync('./.tmp/', {
Expand Down

0 comments on commit d3b84f6

Please sign in to comment.