Install auto-changelog
masterInstall the auto-changelog CLI tool globally via npm to use it in any git repository.
npm install -g auto-changelogrepository·master·Indexed 23 days ago
https://github.com/cookpete/auto-changelogA command-line tool for generating changelogs from git tags and commit history. It supports high customization via CLI flags, configuration files (package.json or .auto-changelog), and Handlebars templates. The tool automatically detects Git providers like GitHub, GitLab, Bitbucket, and Azure DevOps to generate appropriate links, and provides options for custom URL overrides, regex-based commit filtering, and custom Handlebars helpers.
Install the auto-changelog CLI tool globally via npm to use it in any git repository.
npm install -g auto-changelogYou can provide a custom .hbs template file via the --template flag. To see the data structure available to your template, generate a JSON version of the changelog using --template json.
Example template usage:
{{#each releases}}
### [{{title}}]({{href}})
{{#each commits}}
- {{subject}} [`{{shorthash}}`]({{href}})
{{/each}}
{{/each}}auto-changelog --template changelog-template.hbsYou can automate changelog generation by adding auto-changelog -p to your package.json version scripts. Using the -p (or --package) flag tells the tool to use the version from package.json as the latest release, ensuring that all commits since the last tag are included in the current version's section.
{
"name": "my-awesome-package",
"version": "1.0.0",
"devDependencies": {
"auto-changelog": "*"
},
"scripts": {
"version": "auto-changelog -p && git add CHANGELOG.md"
}
}auto-changelog in the root folder of a git repository to generate a CHANGELOG.md file. The tool parses your git history using git log to identify releases based on tags and commit patterns.auto-changelogIf you use a non-standard remote (like Redmine or a custom diff tool), you can override the automatically generated links using tokens {id} for single identifiers or {from} and {to} for version comparisons.
--commit-url [url]: Use {id} for commit IDs.--issue-url [url]: Use {id} for issue IDs.--merge-url [url]: Use {id} for merge IDs.--compare-url [url]: Use {from} and {to} for tag comparisons.# Link all issues to redmine
auto-changelog --issue-url https://www.redmine.org/issues/{id}
# Link to custom diff page
auto-changelog --compare-url https://example.com/repo/compare/{from}...{to}The tool automatically detects the Git provider from your remote URL and generates appropriate links. Supported providers include:
/commits/{id}, /issues/{id}, /pull-requests/{id}, and /compare/{to}..{from}./commit/{id}, /issues/{id}, /merge_requests/{id}, and /compare/{from}...{to}./commit/{id}, /_workitems/edit/{id}, /pullrequest/{id}, and a specific branch comparison URL./commit/{id}, /issues/{id}, /pull/{id}, and /compare/{from}...{to}.You can define configuration options in two ways:
package.json: Use the auto-changelog key with camelCase option names. This takes precedence over other config files..auto-changelog file: A JSON file in your project root.Example package.json configuration:
{
"name": "my-awesome-package",
"auto-changelog": {
"output": "HISTORY.md",
"template": "keepachangelog",
"unreleased": true,
"commitLimit": false
}
}{
"name": "my-awesome-package",
"auto-changelog": {
"output": "HISTORY.md",
"template": "keepachangelog",
"unreleased": true",
"commitLimit": false
}
}Use the replaceText option in your package.json to perform regex-based text replacement in the generated log. This is useful for turning issue IDs into clickable links.
Each pattern is applied using string.replace(new RegExp(key, 'g'), value).
{
"name": "my-awesome-package",
"auto-changelog": {
"replaceText": {
"(ABC-\\d+)": "[`$1`](https://issues.apache.org/jira/browse/$1)"
}
}
}The {{#commit-list}} helper allows you to filter and render specific lists of commits within a template based on regex patterns.
Available options:
heading: A heading to render if at least one commit matches.message: A regex pattern to match against the entire commit message.subject: A regex pattern to match against the commit subject only.exclude: A regex pattern to exclude commits (useful for preventing duplicates).{{#each releases}}
### [{{title}}]({{href}})
{{! List commits with `Breaking change: ` somewhere in the message }}
{{#commit-list commits heading='### Breaking Changes' message='Breaking change: '}}
- {{subject}} [`{{shorthash}}`]({{href}})
{{/commit-list}}
{{! List commits that add new features, not already listed above }}
{{#commit-list commits heading='### New Features' message='feat: ' exclude='Breaking change: '}}
- {{subject}} [`{{shorthash}}`]({{href}})
{{/commit-list}}
{{/each}}Use the --handlebars-setup flag to point to a JavaScript file that registers custom Handlebars helpers for your templates.
auto-changelog --handlebars-setup setup.js --template custom-template.hbs
// setup.js
module.exports = function (Handlebars) {
Handlebars.registerHelper('custom', function (context, options) {
return 'custom helpers!'
})
}You can override the default link generation for commits, issues, merge requests, and comparisons by providing custom URL templates in your configuration. Use the following placeholder tokens within your URL strings:
{id}: Replaced by the commit, issue, or merge request ID.{from}: Replaced by the starting version/tag/branch.{to}: Replaced by the ending version/tag/branch.Supported override keys are commitUrl, issueUrl, mergeUrl, and compareUrl.
The following options are available for the auto-changelog command line interface:
| Option | Description |
|---|---|
-o, --output [file] | Output file, default: CHANGELOG.md |
-c, --config [file] | Config file location, default: .auto-changelog |
-t, --template [template] | Specify template to use [compact, keepachangelog, json], default: compact |
-r, --remote [remote] | Specify git remote to use for links, default: origin |
-p, --package | Use version from package.json as latest release |
-v, --latest-version [version] | Use specified version as latest release |
-u, --unreleased | Include section for unreleased changes |
-l, --commit-limit [count] | Number of commits to display per release, default: 3 |
-b, --backfill-limit [count] | Number of commits to backfill empty releases with, default: 3 |
--commit-url [url] | Override url for commits, use {id} for commit id |
--issue-url [url] | Override url for issues, use {id} for issue id |
--merge-url [url] | Override url for merges, use {id} for merge id |
--compare-url [url] | Override url for compares, use {from} and {to} for tags |
--issue-pattern [regex] | Override regex pattern for issues in commit messages |
--breaking-pattern [regex] | Regex pattern for breaking change commits |
--merge-pattern [regex] | Add custom regex pattern for merge commits |
--commit-pattern [regex] | Pattern to include when parsing commits |
--ignore-commit-pattern [regex] | Pattern to ignore when parsing commits |
--tag-pattern [regex] | Override regex pattern for version tags |
--tag-prefix [prefix] | Prefix used in version tags, default: v |
--autodetect-monorepo-disabled | Disable monorepo autodetection, default: true |
--starting-version [tag] | Specify earliest version to include in changelog |
--starting-date [yyyy-mm-dd] | Specify earliest date to include in changelog |
--ending-version [tag] | Specify latest version to include in changelog |
--sort-commits [property] | Sort commits by property [relevance, date, date-desc, subject, subject-desc], default: relevance |
--release-summary | Display tagged commit message body as release summary |
--unreleased-only | Only output unreleased changes |
--hide-empty-releases | Hide empty releases |
--hide-credit | Hide auto-changelog credit |
--handlebars-setup [file] | Handlebars setup file |
--append-git-log [string] | String to append to git log command |
--append-git-tag [string] | String to append to git tag command |
--prepend | Prepend changelog to output file |
--stdout | Output changelog to stdout |
--plugins [...name] | Use plugins to augment commit/merge/release information |