Skip to content

Commit

Permalink
Merge pull request #2438 from Codeinwp/chore/changelog
Browse files Browse the repository at this point in the history
refactor: keep only the latest release in the changelog
  • Loading branch information
Soare-Robert-Daniel authored Nov 8, 2024
2 parents 38ad8b2 + d327877 commit 5132e80
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 826 deletions.
3 changes: 1 addition & 2 deletions .releaserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins:
- - "@semantic-release/release-notes-generator"
- preset: simple-preset
- - "@semantic-release/exec"
- prepareCmd: "replace-in-file \"== Changelog ==\" \"== Changelog ==\n\n${nextRelease.notes}\" readme.txt"
- prepareCmd: 'export nextReleaseNotes="${nextRelease.notes}" && node bin/update-changelog.mjs'
- - "@semantic-release/exec"
- prepareCmd: grunt version::${nextRelease.version} && grunt wp_readme_to_markdown
- - "semantic-release-slack-bot"
Expand Down Expand Up @@ -43,4 +43,3 @@ plugins:
- plugins/blocks-export-import/readme.txt
message: "chore(release): ${nextRelease.version} \n\n${nextRelease.notes}"
- - "@semantic-release/github"

21 changes: 21 additions & 0 deletions bin/update-changelog.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { replaceInFile } from 'replace-in-file';


async function updateChangelog() {
const options = {
files: 'readme.txt',
from: /== Changelog ==[\s\S]*?\[See changelog for all versions\]/,
to: (match) => {
return `== Changelog ==\n\n${process.env.nextReleaseNotes}\n\n[See changelog for all versions]`;
},
encoding: 'utf8',
};
try {
const results = await replaceInFile(options);
console.log('Replacement results:', results);
} catch (error) {
console.error('Error occurred:', error);
}
}

updateChangelog();
Loading

0 comments on commit 5132e80

Please sign in to comment.