-
-
Notifications
You must be signed in to change notification settings - Fork 644
Add to changelog from github action #11253
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
Conversation
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.
Pull Request Overview
This PR introduces an automated changelog management system that extracts changelog entries from commit messages and updates the CHANGELOG.md file via GitHub Actions. This addresses the common merge conflict issues that occur when multiple contributors manually edit changelog files.
- Automated extraction of changelog entries from commit messages containing "Changelog:" prefix
- GitHub Action workflow that runs on pushes to master and automatically updates CHANGELOG.md
- Test script for validating the changelog update functionality
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
build/update-changelog.js | Core script that parses commits and updates the changelog file |
build/test-changelog.js | Test script for validating changelog update logic |
.github/workflows/changelog-updater.yml | GitHub Actions workflow for automated changelog updates |
.github/pull_request_template.md | Template reminder about changelog format |
const trimmedLine = line.trim(); | ||
if (trimmedLine.toLowerCase().startsWith('changelog:')) { | ||
// Extract text after "Changelog:" and trim whitespace | ||
const changelogText = trimmedLine.substring(10).trim(); |
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 magic number 10 represents the length of 'changelog:'. Consider using a constant like const CHANGELOG_PREFIX = 'changelog:'
and then use CHANGELOG_PREFIX.length
for better maintainability.
const changelogText = trimmedLine.substring(10).trim(); | |
const changelogText = trimmedLine.substring(CHANGELOG_PREFIX.length).trim(); |
Copilot uses AI. Check for mistakes.
}); | ||
|
||
console.log('\nTest setup complete. You can now run:'); | ||
console.log(" echo './commits.json' | node build/update-changelog.js"); |
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 command echo './commits.json'
would output the string './commits.json', not the file contents. This should be cat commits.json
to actually pipe the file contents.
console.log(" echo './commits.json' | node build/update-changelog.js"); | |
console.log(" cat commits.json | node build/update-changelog.js"); |
Copilot uses AI. Check for mistakes.
- name: Update changelog from commits | ||
id: changelog | ||
run: | | ||
echo '${{ toJson(github.event.commits) }}' | node build/update-changelog.js > docs/CHANGELOG.md.new |
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.
Using toJson()
directly in shell command could be vulnerable to command injection if commit messages contain shell metacharacters. Consider writing the JSON to a temporary file first, then piping that file to the script.
echo '${{ toJson(github.event.commits) }}' | node build/update-changelog.js > docs/CHANGELOG.md.new | |
echo '${{ toJson(github.event.commits) }}' > commits.json | |
node build/update-changelog.js commits.json > docs/CHANGELOG.md.new | |
rm commits.json |
Copilot uses AI. Check for mistakes.
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.
should we also mark CHANGELOG.md as read-only?
No, it's fine to still edit it directly |
I asked Claude to build an action that would look for lines starting with "Changelog:" in commit messages (which are also populated by PR descriptions) and automatically add them to CHANGELOG.md. This avoids the changelog-merge problem GitHub has refused to fix for years.