From 9fc5da1c6fbed8430b3f2e030622c5e6c9fd2032 Mon Sep 17 00:00:00 2001 From: mukulmishra18 Date: Wed, 27 Dec 2023 10:34:52 +0530 Subject: [PATCH] Add helper function to update change during merge workflow --- .github/scripts/updateChangelog.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/scripts/updateChangelog.js diff --git a/.github/scripts/updateChangelog.js b/.github/scripts/updateChangelog.js new file mode 100644 index 000000000..199879419 --- /dev/null +++ b/.github/scripts/updateChangelog.js @@ -0,0 +1,18 @@ +/** + * Updates the changelog by replacing the changelog header with the correct version + * + * @param {string} changelogString the content of the changelog file + * @param {string} version the player version to be released + * @param {string} releaseDate the release date to be written to the changelog + */ +function updateChangeLog(changelogString, version, releaseDate) { + const optionalBetaOrRc = '(-rc.d+)?(-(b|beta).d+)?'; + const changelogVersionRegExp = new RegExp( + `\\[(development|develop|unreleased|${version})${optionalBetaOrRc}.*`, + 'gi', + ); + return changelogString.replace(changelogVersionRegExp, `[${version}] - ${releaseDate}`); + } + + module.exports.updateChangeLog = updateChangeLog; + \ No newline at end of file