Reputation: 47088
I'm trying to use conventional-changelog-cli to generate a changelog.
These are some the example outputs provided in the packages README.md
.
And they line up with what I'm trying to get it to do, which is group the commits by the version number.
So for example if under version 1.0.0
there are three commits, then they will render under that version and then if we bump the version to 1.0.1
and make new commits and render the changelog, those commits will show up under that version.
So this is what I've tried.
npm install -g conventional-changelog-cli
mkdir cl && cd cl && npm init -y && git init
git add . && git commit -m "fix: add project scaffolding"
conventional-changelog -p angular -i CHANGELOG.md -s
After this is done the changelog looks like this:
# 1.0.0 (2024-03-15)
### Bug Fixes
* project scaffolding f2da8ba
Next I bump to 1.0.1
and we add a index.js
file like this and rerun the changelog generation this.
touch index.js
git add . && git commit -m "feat: add index.js with hello world logging"
conventional-changelog -p angular -i CHANGELOG.md -s
And now the changelog looks like this:
## 1.0.1 (2024-03-15)
### Bug Fixes
* add project scaffolding 38bc9ba
### Features
* add index.js with hello world logging 289395a
# 1.0.0 (2024-03-15)
### Bug Fixes
* add project scaffolding 38bc9ba
And as can be seen this part is repeated under version 1.0.1
:
### Bug Fixes
* add project scaffolding 38bc9ba
How do we run the cli so that it does not duplicate content under new versions?
Upvotes: 0
Views: 592
Reputation: 656
The conventional changelog package generates the changelog based on the latest Git semver tag by default.
This is why the recommended workflow is to commit the generated CHANGELOG and tag the release.
You can modify the default behavior by specifying a tag, commit hash, or reference in a JavaScript or JSON configuration file.
For example, the following configuration will generate the changelog since the commit of the two versions prior to the current HEAD:
{
"gitRawCommitsOpts": {
"from": "HEAD~2"
}
}
To generate the changelog using this custom configuration, you can run the following command:
npx conventional-changelog --config config.json
Upvotes: 1