chore: new post-bump script

This commit is contained in:
JOYCEQL
2026-03-02 00:37:28 +08:00
parent 7dda46a82e
commit 0a9d71b355
2 changed files with 25 additions and 1 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
import { defineConfig } from 'bumpp'
export default defineConfig({
execute: 'npx changelogen --output CHANGELOG.md && node -e "const fs=require(\'fs\'); const pkg=require(\'./package.json\'); let c=fs.readFileSync(\'CHANGELOG.md\',\'utf8\'); c=c.replace(/## v[\\d.]+...main/g, \'## v\' + pkg.version); fs.writeFileSync(\'CHANGELOG.md\', c);"',
execute: 'node scripts/post-bump.mjs',
commit: true,
tag: true,
push: false,
+24
View File
@@ -0,0 +1,24 @@
import { execSync } from 'node:child_process';
import { readFileSync, writeFileSync } from 'node:fs';
import { resolve } from 'node:path';
const root = process.cwd();
console.log('Generating changelog...');
execSync('npx changelogen --output CHANGELOG.md', { stdio: 'inherit' });
const pkgPath = resolve(root, 'package.json');
const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
const version = pkg.version;
const changelogPath = resolve(root, 'CHANGELOG.md');
let content = readFileSync(changelogPath, 'utf8');
const regex = /## v[\d.]+...main/g;
if (regex.test(content)) {
console.log(`Fixing changelog header for v${version}...`);
content = content.replace(regex, `## v${version}`);
writeFileSync(changelogPath, content);
}
console.log('Post-bump script completed successfully.');