Automatic Changelog Generation with semantic-release
Configure semantic-release to automatically create and maintain a CHANGELOG.md file. Uses @semantic-release/changelog and @semantic-release/git to commit the changelog back to the repository.
Detailed Explanation
Automatic CHANGELOG.md Generation
Adding a changelog to your semantic-release workflow requires two additional plugins: @semantic-release/changelog to generate the file and @semantic-release/git to commit it back to your repository.
Configuration
{
"branches": ["main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
["@semantic-release/changelog", {
"changelogFile": "CHANGELOG.md"
}],
"@semantic-release/npm",
"@semantic-release/github",
["@semantic-release/git", {
"assets": ["CHANGELOG.md", "package.json", "package-lock.json"],
"message": "chore(release): ${nextRelease.version} [skip ci]"
}]
]
}
Plugin Order Matters
The order of plugins in the array is critical:
- commit-analyzer must come first to determine the release type
- release-notes-generator generates the notes used by both changelog and github
- changelog writes CHANGELOG.md using the generated notes
- npm updates package.json version
- github creates the GitHub release
- git must come last — it commits all file changes made by previous plugins
The [skip ci] Commit Message
The commit message template includes [skip ci] to prevent the changelog commit from triggering another CI run, which would create an infinite loop. Most CI systems (GitHub Actions, GitLab CI, CircleCI) recognize this flag.
Changelog Format
The generated CHANGELOG.md follows the Keep a Changelog convention with entries grouped by version and sorted by commit type.
Use Case
Projects that want a persistent CHANGELOG.md in their repository for documentation purposes, package registries that display changelogs, or teams that require a change history for compliance and audit trails.
Try It — Semantic Release Config Builder
Related Topics
Basic npm Package Release with semantic-release
Basic Configuration
Commit Release Artifacts Back to Repository
Advanced Configuration
Using conventionalcommits Preset with semantic-release
Plugin Configuration
Custom Commit Type Release Rules for semantic-release
Advanced Configuration
Monorepo semantic-release Configuration
Advanced Configuration