Skip to content

Commit

Permalink
Add script to bump changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
ericglau committed Aug 24, 2022
1 parent d9e969b commit 4796e6f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/core-cairo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"prepare": "tsc",
"prepublish": "rimraf dist *.tsbuildinfo",
"test": "ava",
"test:watch": "ava --watch"
"test:watch": "ava --watch",
"version": "node ../../scripts/bump-changelog.js"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"prepare": "tsc && node dist/scripts/prepare.js",
"prepublish": "rimraf dist *.tsbuildinfo && hardhat clean",
"test": "ava",
"test:watch": "ava --watch"
"test:watch": "ava --watch",
"version": "node ../../scripts/bump-changelog.js"
},
"devDependencies": {
"@openzeppelin/contracts": "4.7.3",
Expand Down
19 changes: 19 additions & 0 deletions scripts/bump-changelog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env node

const { version } = require(process.cwd() + '/package.json');
const [date] = new Date().toISOString().split('T');

const fs = require('fs');
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');

const unreleased = /^## Unreleased$/im;

if (!unreleased.test(changelog)) {
console.error('Missing changelog entry');
process.exit(1);
}

fs.writeFileSync('CHANGELOG.md', changelog.replace(unreleased, `## ${version} (${date})`));

const proc = require('child_process');
proc.execSync('git add CHANGELOG.md', { stdio: 'inherit' });

0 comments on commit 4796e6f

Please sign in to comment.