chore(release): create a github release on new version

This commit is contained in:
Corentin Thomasset 2023-04-14 18:44:22 +02:00
parent 85cb0ffabd
commit dbad7730f9
No known key found for this signature in database
GPG key ID: DBD997E935996158
8 changed files with 356 additions and 819 deletions

View file

@ -0,0 +1,15 @@
import { readFile, writeFile } from 'fs/promises';
export { addToChangelog };
async function addToChangelog({ changelog, version, changelogPath = './CHANGELOG.md' }) {
const changelogContent = await readFile(changelogPath, 'utf-8');
const versionTitle = `## Version ${version}`;
if (changelogContent.includes(versionTitle)) {
throw new Error(`Version ${version} already exists in the changelog`);
}
const newChangeLogContent = changelogContent.replace('## ', `${versionTitle}\n\n${changelog}\n\n## `);
await writeFile(changelogPath, newChangeLogContent, 'utf-8');
}