Command line tool for generating a changelog from git tags and commit history
Installations
npm install auto-changelog
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>=8.3
Node Version
20.12.0
NPM Version
10.5.0
Score
72.7
Supply Chain
98.4
Quality
76.7
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (93.38%)
Handlebars (6.62%)
Developer
CookPete
Download Statistics
Total Downloads
23,303,887
Last Day
22,047
Last Week
110,790
Last Month
520,986
Last Year
7,016,331
GitHub Statistics
1,301 Stars
330 Commits
158 Forks
16 Watching
10 Branches
30 Contributors
Bundle Size
138.16 kB
Minified
42.32 kB
Minified + Gzipped
Package Meta Information
Latest Version
2.5.0
Package Id
auto-changelog@2.5.0
Unpacked Size
83.27 kB
Size
24.46 kB
File Count
17
NPM Version
10.5.0
Node Version
20.12.0
Publised On
11 Sept 2024
Total Downloads
Cumulative downloads
Total Downloads
23,303,887
Last day
-7.1%
22,047
Compared to previous day
Last week
-14.7%
110,790
Compared to previous week
Last month
-2.6%
520,986
Compared to previous month
Last year
8%
7,016,331
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
auto-changelog
Command line tool for generating a changelog from git tags and commit history. Used by Modernizr, Netlify, Neutrino and Velocity.js.
Installation
1npm install -g auto-changelog
Usage
Simply run auto-changelog
in the root folder of a git repository. git log
is run behind the scenes in order to parse the commit history.
1Usage: auto-changelog [options] 2 3Options: 4 5 -o, --output [file] # output file, default: CHANGELOG.md 6 -c, --config [file] # config file location, default: .auto-changelog 7 -t, --template [template] # specify template to use [compact, keepachangelog, json], default: compact 8 -r, --remote [remote] # specify git remote to use for links, default: origin 9 -p, --package # use version from package.json as latest release 10 -v, --latest-version [version] # use specified version as latest release 11 -u, --unreleased # include section for unreleased changes 12 -l, --commit-limit [count] # number of commits to display per release, default: 3 13 -b, --backfill-limit [count] # number of commits to backfill empty releases with, default: 3 14 --commit-url [url] # override url for commits, use {id} for commit id 15 --issue-url [url] # override url for issues, use {id} for issue id 16 --merge-url [url] # override url for merges, use {id} for merge id 17 --compare-url [url] # override url for compares, use {from} and {to} for tags 18 --issue-pattern [regex] # override regex pattern for issues in commit messages 19 --breaking-pattern [regex] # regex pattern for breaking change commits 20 --merge-pattern [regex] # add custom regex pattern for merge commits 21 --commit-pattern [regex] # pattern to include when parsing commits 22 --ignore-commit-pattern [regex] # pattern to ignore when parsing commits 23 --tag-pattern [regex] # override regex pattern for version tags 24 --tag-prefix [prefix] # prefix used in version tags, default: v 25 --starting-version [tag] # specify earliest version to include in changelog 26 --starting-date [yyyy-mm-dd] # specify earliest date to include in changelog 27 --ending-version [tag] # specify latest version to include in changelog 28 --sort-commits [property] # sort commits by property [relevance, date, date-desc, subject, subject-desc], default: relevance 29 --release-summary # display tagged commit message body as release summary 30 --unreleased-only # only output unreleased changes 31 --hide-empty-releases # hide empty releases 32 --hide-credit # hide auto-changelog credit 33 --handlebars-setup [file] # handlebars setup file 34 --append-git-log [string] # string to append to git log command 35 --append-git-tag [string] # string to append to git tag command 36 --prepend # prepend changelog to output file 37 --stdout # output changelog to stdout 38 --plugins [...name] # use plugins to augment commit/merge/release information 39 -V, --version # output the version number 40 -h, --help # output usage information 41 42 43# Write log to CHANGELOG.md in current directory 44auto-changelog 45 46# Write log to HISTORY.md using keepachangelog template 47auto-changelog --output HISTORY.md --template keepachangelog 48 49# Disable the commit limit, rendering all commits for every release 50auto-changelog --commit-limit false
Requirements
auto-changelog
is designed to be as flexible as possible, providing a clear changelog for any project. There are only two absolute requirements:
- You should be using git
1.7.2
or later - All versions should be tagged using semver tag names – this happens by default when using
npm version
There are some less strict requirements to improve your changelog:
- Close issues using keywords
- Merge pull requests using the standard merge commit message for your platform
What you might do if you’re clever
Install auto-changelog
to dev dependencies:
1npm install auto-changelog --save-dev 2# or 3yarn add auto-changelog --dev
Add auto-changelog -p && git add CHANGELOG.md
to the version
scripts in your package.json
:
1{ 2 "name": "my-awesome-package", 3 "version": "1.0.0", 4 "devDependencies": { 5 "auto-changelog": "*" 6 }, 7 "scripts": { 8 "version": "auto-changelog -p && git add CHANGELOG.md" 9 } 10}
Using -p
or --package
uses the version
from package.json
as the latest release, so that all commits between the previous release and now become part of that release. Essentially anything that would normally be parsed as Unreleased
will now come under the version
from package.json
Now every time you run npm version
, the changelog will automatically update and be part of the version commit.
Advanced Usage
URL Overrides
Links to commits, issues, pull requests and version diffs are automatically generated based on your remote URL. GitHub, GitLab, BitBucket and Azure DevOps are all supported. If you have an unusual remote or need to override one of the link formats, use --commit-url
, --issue-url
or --merge-url
with an {id}
token. For custom version diffs, use --compare-url
with {from}
and {to}
tokens.
1# Link all issues to redmine 2auto-changelog --issue-url https://www.redmine.org/issues/{id} 3 4# Link to custom diff page 5auto-changelog --compare-url https://example.com/repo/compare/{from}...{to}
Add to an existing changelog
If you’d like to keep an existing changelog below your generated one, just add <!-- auto-changelog-above -->
to your current changelog. The generated changelog will be added above this token, and anything below will remain.
Configuration
You can set any option in package.json
under the auto-changelog
key, using camelCase options.
1{ 2 "name": "my-awesome-package", 3 "version": "1.0.0", 4 "scripts": { 5 // ... 6 }, 7 "auto-changelog": { 8 "output": "HISTORY.md", 9 "template": "keepachangelog", 10 "unreleased": true, 11 "commitLimit": false 12 } 13}
You can also store config options in an .auto-changelog
file in your project root:
1{ 2 "output": "HISTORY.md", 3 "template": "keepachangelog", 4 "unreleased": true, 5 "commitLimit": false 6}
Note that any options set in package.json
will take precedence over any set in .auto-changelog
.
Tag prefixes
Use --tag-prefix [prefix]
if you prefix your version tags with a certain string:
1# When all versions are tagged like my-package/1.2.3 2auto-changelog --tag-prefix my-package/
Tag patterns
By default, auto-changelog
looks for valid semver tags to build a list of releases. If you are using another format (or want to include all tags), use --tag-pattern [regex]
:
1# When all versions are tagged like build-12345 2auto-changelog --tag-pattern build-\d+ 3 4# Include any tag as a release 5auto-changelog --tag-pattern .+
Breaking changes
If you use a common pattern in your commit messages for breaking changes, use --breaking-pattern
to highlight those commits as breaking changes in your changelog. Breaking change commits will always be listed as part of a release, regardless of any --commit-limit
set.
1auto-changelog --breaking-pattern "BREAKING CHANGE:"
Custom issue patterns
By default, auto-changelog
will parse GitHub-style issue fixes in your commit messages. If you use Jira or an alternative pattern in your commits to reference issues, you can pass in a custom regular expression to --issue-pattern
along with --issue-url
:
1# Parse Jira-style issues in your commit messages, like PROJECT-418 2auto-changelog --issue-pattern [A-Z]+-\d+ --issue-url https://issues.apache.org/jira/browse/{id}
Or, in your package.json
:
1{ 2 "name": "my-awesome-package", 3 "auto-changelog": { 4 "issueUrl": "https://issues.apache.org/jira/browse/{id}", 5 "issuePattern": "[A-Z]+-\d+" 6 } 7}
If you use a certain pattern before or after the issue number, like fixes {id}
, just use a capturing group:
1# "This commit fixes ISSUE-123" will now parse ISSUE-123 as an issue fix 2auto-changelog --issue-pattern "[Ff]ixes ([A-Z]+-\d+)"
Custom templates
If you aren’t happy with the default templates or want to tweak something, you can point to a handlebars template in your local repo. Check out the existing templates to see what is possible.
Save changelog-template.hbs
somewhere in your repo:
1### Changelog 2My custom changelog template. Don’t worry about indentation here; it is automatically removed from the output. 3 4{{#each releases}} 5 Every release has a {{title}} and a {{href}} you can use to link to the commit diff. 6 It also has an {{isoDate}} and a {{niceDate}} you might want to use. 7 {{#each merges}} 8 - A merge has a {{message}}, an {{id}} and a {{href}} to the PR. 9 {{/each}} 10 {{#each fixes}} 11 - Each fix has a {{commit}} with a {{commit.subject}}, an {{id}} and a {{href}} to the fixed issue. 12 {{/each}} 13 {{#each commits}} 14 - Commits have a {{shorthash}}, a {{subject}} and a {{href}}, {{author}} amongst other things. 15 {{/each}} 16{{/each}}
Then just use --template
to point to your template:
1auto-changelog --template changelog-template.hbs
You can also point to an external template by passing in a URL:
1auto-changelog --template https://example.com/templates/compact.hbs
To see exactly what data is passed in to the templates, you can generate a JSON version of the changelog:
1auto-changelog --template json --output changelog-data.json
commit-list
helper
Use {{#commit-list}}
to render a list of commits depending on certain patterns in the commit messages:
1{{#each releases}} 2 ### [{{title}}]({{href}}) 3 4 {{! List commits with `Breaking change: ` somewhere in the message }} 5 {{#commit-list commits heading='### Breaking Changes' message='Breaking change: '}} 6 - {{subject}} [`{{shorthash}}`]({{href}}) 7 {{/commit-list}} 8 9 {{! List commits that add new features, but not those already listed above }} 10 {{#commit-list commits heading='### New Features' message='feat: ' exclude='Breaking change: '}} 11 - {{subject}} [`{{shorthash}}`]({{href}}) 12 {{/commit-list}} 13{{/each}}
Option | Description |
---|---|
heading | A heading for the list, only renders 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 from the list – useful for avoiding listing commits more than once |
Replacing text
To insert links or other markup to PR titles and commit messages that appear in the log, use the replaceText
option in your package.json
:
1{ 2 "name": "my-awesome-package", 3 "auto-changelog": { 4 "replaceText": { 5 "(ABC-\\d+)": "[`$1`](https://issues.apache.org/jira/browse/$1)" 6 } 7 } 8}
Here, any time a pattern like ABC-123
appears in your log, it will be replaced with a link to the relevant issue in Jira. Each pattern is applied using string.replace(new RegExp(key, 'g'), value)
.
Handlebars setup file
The --handlebars-setup
options allows you to point to a file to add custom Handlebars helpers, for use in custom templates using --template
. Paths are relative to the directory in which you run auto-changelog
.
1auto-changelog --handlebars-setup setup.js --template custom-template.hbs 2 3// setup.js 4module.exports = function (Handlebars) { 5 Handlebars.registerHelper('custom', function (context, options) { 6 return 'custom helpers!' 7 }) 8} 9 10// custom-template.hbs 11Now you can use {{custom}}
FAQ
What’s a changelog?
See keepachangelog.com.
What does this do?
The command parses your git commit history and generates a changelog based on tagged versions, merged pull requests and closed issues. See a simple example in this very repo.
Why do I need it?
Because keeping a changelog can be tedious and difficult to get right. If you don’t have the patience for a hand-crafted, bespoke changelog then this makes keeping one rather easy. It also can be automated if you’re feeling extra lazy.
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.md:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.md:0
Reason
Found 12/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 12 are checked with a SAST tool
Reason
11 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-6vfc-qv3f-vr6c
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
2.3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreGathering detailed insights and metrics for auto-changelog