From b09f92e0a48c84ff7536071fc0628be9064d67c8 Mon Sep 17 00:00:00 2001 From: kobenguyent Date: Mon, 9 Oct 2023 10:19:19 +0200 Subject: [PATCH] fix: improve the versioning function --- runok.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/runok.js b/runok.js index 78db397cf..8e600bd44 100755 --- a/runok.js +++ b/runok.js @@ -422,9 +422,25 @@ title: ${name} const newVersion = semver.inc(packageFile.version, type); packageFile.version = newVersion; - fs.writeFileSync('./package.json', JSON.stringify(packageFile, null, 2)); + fs.writeFileSync('./package.json', (JSON.stringify(packageFile, null, 2)).replace(/(^[ \t]*\n)/gm, '')); console.log('Version updated', currentVersion, '=>', newVersion); + const file = 'CHANGELOG.md'; + const changelog = fs.readFileSync(file).toString(); + + const _changelog = `## ${newVersion}\n +Thanks all to those who contributed to make this release! + +🐛 *Bug Fixes* + +📖 *Documentation* + +🛩ī¸ *Features* + +${changelog}`; + + fs.writeFileSync(`./${file}`, _changelog); + console.log('Creating and switching to release branch...'); await exec(`git checkout -b release-${newVersion}`); }