-
Notifications
You must be signed in to change notification settings - Fork 9
Refactor release preparation workflow and add automated changelog upd… #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| #!/usr/bin/env node | ||
| // This script updates CHANGELOG.md with a new release section | ||
| // Usage: node update-changelog.js <version> <date> <changelog-file> | ||
|
|
||
| const fs = require('fs'); | ||
|
|
||
| const [,, version, releaseDate, changelogFile] = process.argv; | ||
|
|
||
| if (!version || !releaseDate || !changelogFile) { | ||
| console.error('Usage: node update-changelog.js <version> <date> <changelog-file>'); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| const changelogContent = fs.readFileSync(changelogFile, 'utf8').trim(); | ||
| let content = fs.readFileSync('CHANGELOG.md', 'utf8'); | ||
|
|
||
| const newSection = `## v${version} (${releaseDate}) | ||
|
|
||
| ### Changes | ||
|
|
||
| ${changelogContent} | ||
|
Comment on lines
+17
to
+21
|
||
| `; | ||
|
|
||
| // Find the Upcoming section and insert after it | ||
| const upcomingMatch = content.match(/## Upcoming[\s\S]*?(?=\n## v|$)/); | ||
| if (upcomingMatch) { | ||
| const upcomingEnd = content.indexOf(upcomingMatch[0]) + upcomingMatch[0].length; | ||
| content = content.slice(0, upcomingEnd) + '\n' + newSection + content.slice(upcomingEnd); | ||
| } else { | ||
| content = '## Upcoming\n\n' + newSection + content; | ||
| } | ||
|
|
||
| // Reset the Upcoming section to empty | ||
| content = content.replace(/## Upcoming[\s\S]*?(?=\n## v)/, '## Upcoming\n\n### New\n\n### Fixes\n\n'); | ||
|
|
||
| fs.writeFileSync('CHANGELOG.md', content); | ||
| console.log('Updated CHANGELOG.md'); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The script’s CLI contract/documentation is misleading: the third arg is named like a changelog file to update, but the script always reads/writes the hard-coded
CHANGELOG.mdand uses the arg only as the source of release notes. Consider renaming the arg/usage text (e.g.,release-notes-file) or adding an explicit target path parameter and using it instead of hard-codingCHANGELOG.md.