Skip to content

Commit

Permalink
fix(release): Fix bug where CHANGELOG.md only updated in @latest channel
Browse files Browse the repository at this point in the history
  • Loading branch information
jlacivita committed Apr 18, 2023
1 parent 9f068cf commit 9d96665
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/js/production-changelog/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ async function prepare(config, { cwd, nextRelease, logger }) {
const logPath = path.resolve(cwd, changelogFile)

// scrub prerelease notes if this release is not a prerelease
if (notes && nextRelease.channel === 'latest') {
if (notes) {
await ensureFile(logPath)
const currentFile = (await readFile(logPath)).toString().trim()

Expand All @@ -21,13 +21,15 @@ async function prepare(config, { cwd, nextRelease, logger }) {
? currentFile.slice(changelogTitle.length).trim()
: currentFile;

logger.log(`Scrubbing prerelease notes from ${logPath}.`)
if (nextRelease.channel === 'latest') {
logger.log(`Scrubbing prerelease notes from ${logPath}.`)

// Looking for things like:
//# [0.10.0-next.5](https://github.com/rdkcentral/firebolt-core-sdk/compare/v0.10.0-next.4...v0.10.0-next.5) (2023-02-01)
const regex = /\# \[[0-9]+\.[0-9]+\.[0-9]+\-[^\]]+\].*?\n+\# /gms
while (content.match(regex)) {
content = content.replace(regex, '\n# ')
// Looking for things like:
//# [0.10.0-next.5](https://github.com/rdkcentral/firebolt-core-sdk/compare/v0.10.0-next.4...v0.10.0-next.5) (2023-02-01)
const regex = /\# \[[0-9]+\.[0-9]+\.[0-9]+\-[^\]]+\].*?\n+\# /gms
while (content.match(regex)) {
content = content.replace(regex, '\n# ')
}
}

content = `${notes.trim()}\n${content ? `\n${content}\n` : ''}`;
Expand Down

0 comments on commit 9d96665

Please sign in to comment.