Skip to content

Commit b161114

Browse files
authoredDec 7, 2024··
Add git-cliff example (#1176)
1 parent 28213bf commit b161114

File tree

3 files changed

+71
-0
lines changed

3 files changed

+71
-0
lines changed
 

‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ message conventions. Plugins are available for:
181181
- auto-changelog
182182
- Conventional Changelog
183183
- Keep A Changelog
184+
- git-cliff
184185

185186
To print the changelog without releasing anything, add the `--changelog` flag.
186187

‎docs/changelog.md

+11
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ these commands output the changelog to `stdout`.
1010
- [auto-changelog][3]
1111
- [Conventional Changelog][4]
1212
- [Keep A Changelog][5]
13+
- [git-cliff][14]
1314

1415
Some projects keep their changelog in e.g. `CHANGELOG.md` or `history.md`. To auto-update this file and include this in
1516
the release commit, the recommended configuration is to do this in the `after:bump` hook (see example below).
@@ -92,6 +93,14 @@ This plugin updates `CHANGELOG.md` file according to
9293
}
9394
```
9495

96+
## Git-cliff
97+
98+
Git-cliff is a customizable changelog generator that follows
99+
Conventional Commit specifications. Similar to auto-changelog, it can be used
100+
as a companion to release-it.
101+
102+
See the [git-cliff recipe][15] for an example setup.
103+
95104
[1]: ../config/release-it.json
96105
[2]: #github-and-gitlab-releases
97106
[3]: #auto-changelog
@@ -105,3 +114,5 @@ This plugin updates `CHANGELOG.md` file according to
105114
[11]: https://github.com/release-it/conventional-changelog
106115
[12]: https://keepachangelog.com
107116
[13]: https://github.com/release-it/keep-a-changelog
117+
[14]: https://github.com/orhun/git-cliff
118+
[15]: ./recipes/git-cliff.md

‎docs/recipes/git-cliff.md

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# Git-cliff
2+
3+
Please refer to [git-cliff documentation][1] for more details and usage.
4+
5+
## Config
6+
7+
Add git-cliff to the project:
8+
9+
```bash
10+
npm install --save-dev git-cliff
11+
```
12+
13+
Git-cliff has the ability to use the Conventional Commits convention
14+
to automatically set the package version.
15+
Release-it allows the user to select the version that should be released.
16+
Therefore, it may be helpful to generate the changelog from the version in the
17+
`package.json` that was bumped by release-it.
18+
19+
```sh
20+
#!/usr/bin/env bash
21+
22+
NODE_VERSION=$(node -p -e "require('./package.json').version")
23+
24+
if [ "$1" = "stdout" ]; then
25+
npm exec git-cliff -o - --unreleased --tag $NODE_VERSION
26+
else
27+
npm exec git-cliff -o './CHANGELOG.md' --tag $NODE_VERSION
28+
fi
29+
```
30+
31+
Example configuration in the release-it config:
32+
33+
```json
34+
{
35+
"hooks": {
36+
"after:bump": "./changelog.sh"
37+
},
38+
"github": {
39+
"releaseNotes": "./changelog.sh stdout"
40+
}
41+
}
42+
```
43+
44+
## Template
45+
46+
Git-cliff uses Tera as a templating language, which is inspired by Jinja2 and
47+
Django templates.
48+
49+
See [git-cliff syntax docs][2] for more information.
50+
51+
## Monorepos
52+
53+
Git-cliff has a `--include-path` flag to scope changes to a specific directory path.
54+
55+
See [git-cliff monorepo docs][3] for more information.
56+
57+
[1]: https://github.com/orhun/git-cliff
58+
[2]: https://git-cliff.org/docs/templating/examples
59+
[3]: https://git-cliff.org/docs/usage/monorepos

0 commit comments

Comments
 (0)
Please sign in to comment.