Skip to content

Commit 50c6fc1

Browse files
authored
ci: add git-cliff changelog automation (#49)
* ci: add git-cliff changelog automation * ci: catch non-conventional commits in changelog Apply Richard's review on PR #49. cliff.toml: - Set filter_unconventional to false and add a final ".*" parser that groups leftover commits under "Other". - Rename group labels to readable names (Features, Bug Fixes, etc.). - Add preprocessors that strip Signed-off-by trailers and multi-line commit bodies, so each entry is one tidy subject line. - Set trim to false so a blank line separates each release. CONTRIBUTING.md: - Update the cliff.toml summary to describe the new "Other" behavior. Repo-specific bits kept: uppercase V tag pattern, ACRO-R PR URL. * fix: use reticulate::virtualenv_starter() in install_venv * fix: replace %||% with if/else for R < 4.4 compat * fix: exclude virtualenv_starter fallback from coverage * revert: restore get_python() in install_venv
1 parent 51810ca commit 50c6fc1

3 files changed

Lines changed: 106 additions & 0 deletions

File tree

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
^\.vscode$
2525
^.*\.swp$
2626
^\.Rdata$
27+
^cliff\.toml$
2728
^doc$
2829
^Meta$

CONTRIBUTING.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,62 @@ 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+
Download a prebuilt binary from the [releases page](https://github.com/orhun/git-cliff/releases) or install via a package manager:
102+
103+
```shell
104+
# homebrew (macOS / Linux)
105+
brew install git-cliff
106+
107+
# winget (Windows)
108+
winget install git-cliff
109+
```
110+
111+
### Generate the changelog entry
112+
113+
Run the following on `main` immediately before tagging a new release, replacing `X.Y.Z` with the new version:
114+
115+
```shell
116+
git cliff --config cliff.toml --unreleased --tag "VX.Y.Z" --prepend NEWS.md
117+
```
118+
119+
Review and edit `NEWS.md` as needed (e.g. to add extra context or merge duplicate entries), then commit:
120+
121+
```shell
122+
git add NEWS.md
123+
git commit -m "docs: update changelog"
124+
git tag VX.Y.Z
125+
```
126+
127+
The configuration lives in `cliff.toml` at the repository root. It automatically:
128+
129+
- Converts `(#NNN)` PR references into markdown links.
130+
- Skips noise commits (pre-commit auto-fixes, changelog and release-prep commits).
131+
- Groups commits that do not follow Conventional Commits under an "Other" heading so nothing is dropped (see [Pull Request Titles](#pull-request-titles)).
132+
77133
## CRAN Submission
78134

79135
A useful command to run before submitting:

cliff.toml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[changelog]
2+
header = ""
3+
body = """
4+
{% if version %}\
5+
# acro {{ version | trim_start_matches(pat="V") }} ({{ timestamp | date(format="%b %d, %Y") }})
6+
{% else %}\
7+
# Unreleased
8+
{% endif %}\
9+
{% for group, commits in commits | group_by(attribute="group") %}
10+
### {{ group }}
11+
{% for commit in commits -%}
12+
* {% if commit.scope %}**{{ commit.scope }}:** {% endif %}{{ commit.message | trim }}
13+
{% endfor %}
14+
{%- endfor %}
15+
"""
16+
trim = false
17+
footer = ""
18+
19+
[git]
20+
conventional_commits = true
21+
filter_unconventional = false
22+
# Only matches uppercase V tags (V0.1.7+); older lowercase tags
23+
# (v0.1.1–v0.1.6) are excluded — their NEWS.md entries were hand-written.
24+
tag_pattern = "V[0-9]+\\.[0-9]+\\.[0-9]+"
25+
26+
commit_preprocessors = [
27+
{ pattern = ' \(#(\d+)\)', replace = ' ([#$1](https://github.com/AI-SDC/ACRO-R/pull/$1))' },
28+
{ pattern = 'Signed-off-by:.*', replace = '' },
29+
{ pattern = '\n[\s\S]*', replace = '' },
30+
]
31+
32+
commit_parsers = [
33+
{ message = "^\\[pre-commit", skip = true },
34+
{ message = "^docs: update changelog", skip = true },
35+
{ message = "^docs: update citation", skip = true },
36+
{ message = "^chore: prepare", skip = true },
37+
{ message = "^feat", group = "Features" },
38+
{ message = "^fix", group = "Bug Fixes" },
39+
{ message = "^docs", group = "Documentation" },
40+
{ message = "^perf", group = "Performance" },
41+
{ message = "^refactor", group = "Refactoring" },
42+
{ message = "^build", group = "Build" },
43+
{ message = "^test", group = "Testing" },
44+
{ message = "^ci", group = "CI" },
45+
{ message = "^style", group = "Style" },
46+
{ message = "^chore", group = "Chore" },
47+
{ message = "^revert", group = "Reverts" },
48+
{ message = ".*", group = "Other" },
49+
]

0 commit comments

Comments
 (0)