Skip to content

Commit 9a0af2b

Browse files
committed
ci: added git-cliff changelog automation
1 parent 3407798 commit 9a0af2b

2 files changed

Lines changed: 99 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,63 @@ writeLines(pak::pkg_system_requirements("devtools", "ubuntu", "22.04"))
7474
To remove the local virtual Python environment, delete the `r-acro` folder.
7575
On GNU/Linux this is typically located in `~/.virtualenvs`
7676

77+
## Pull Request Titles
78+
79+
Use [Conventional Commits](https://www.conventionalcommits.org) for PR titles (squash-merge messages). This allows automated changelog generation. Common prefixes:
80+
81+
```
82+
feat — new feature
83+
fix — bug fix
84+
docs — documentation changes
85+
style — formatting/styling (no code logic)
86+
refactor — code changes without feature/bug impact
87+
perf — performance improvements
88+
test — adding/updating tests
89+
build — changes to build system or dependencies
90+
ci — changes to CI config/scripts
91+
chore — miscellaneous maintenance tasks
92+
revert — reverts an earlier commit
93+
```
94+
95+
## Release Workflow
96+
97+
`NEWS.md` is generated locally before each release using [git-cliff](https://github.com/orhun/git-cliff). It reads merged PR titles (via squash-merge commit messages) since the last release tag and formats them to match the existing changelog style.
98+
99+
### Install git-cliff
100+
101+
```shell
102+
# pip
103+
pip install git-cliff
104+
105+
# uv
106+
uv tool install git-cliff
107+
108+
# homebrew (macOS / Linux)
109+
brew install git-cliff
110+
```
111+
112+
### Generate the changelog entry
113+
114+
Run the following on `main` immediately before tagging a new release, replacing `X.Y.Z` with the new version:
115+
116+
```shell
117+
git cliff --config cliff.toml --unreleased --tag "VX.Y.Z" --prepend NEWS.md
118+
```
119+
120+
Review and edit `NEWS.md` as needed (e.g. to add extra context or merge duplicate entries), then commit:
121+
122+
```shell
123+
git add NEWS.md
124+
git commit -m "docs: update changelog"
125+
git tag VX.Y.Z
126+
```
127+
128+
The configuration lives in `cliff.toml` at the repository root. It automatically:
129+
130+
- Converts `(#NNN)` PR references into markdown links.
131+
- Skips noise commits (pre-commit auto-fixes, changelog and release-prep commits).
132+
- Filters out commits that do not follow Conventional Commits (see [Pull Request Titles](#pull-request-titles)).
133+
77134
## CRAN Submission
78135

79136
A useful command to run before submitting:

cliff.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[changelog]
2+
header = ""
3+
body = """
4+
{% if version %}\
5+
# acro {{ version | trim_start_matches(pat="v") }}
6+
7+
{% else %}\
8+
# Unreleased
9+
10+
{% endif %}\
11+
{% for commit in commits -%}
12+
* {% if commit.scope %}{{ commit.group }}({{ commit.scope }}): {% else %}{{ commit.group }}: {% endif %}{{ commit.message | trim }}
13+
{% endfor %}\
14+
"""
15+
trim = true
16+
footer = ""
17+
18+
[git]
19+
conventional_commits = true
20+
filter_unconventional = true
21+
tag_pattern = "V[0-9]+\\.[0-9]+\\.[0-9]+"
22+
23+
commit_preprocessors = [
24+
{ pattern = ' \(#(\d+)\)', replace = ' ([#$1](https://github.com/AI-SDC/ACRO-R/pull/$1))' },
25+
]
26+
27+
commit_parsers = [
28+
{ message = "^\\[pre-commit", skip = true },
29+
{ message = "^docs: update changelog", skip = true },
30+
{ message = "^chore: prepare", skip = true },
31+
{ message = "^feat", group = "feat" },
32+
{ message = "^fix", group = "fix" },
33+
{ message = "^docs", group = "docs" },
34+
{ message = "^chore", group = "chore" },
35+
{ message = "^ci", group = "ci" },
36+
{ message = "^refactor", group = "refactor" },
37+
{ message = "^test", group = "test" },
38+
{ message = "^build", group = "build" },
39+
{ message = "^perf", group = "perf" },
40+
{ message = "^style", group = "style" },
41+
{ message = "^revert", group = "revert" },
42+
]

0 commit comments

Comments
 (0)