Skip to content

Commit 0f1a348

Browse files
authored
Move logic for release notes generation from Python script to Jinja template (release CI) (#44)
1 parent afd9198 commit 0f1a348

File tree

3 files changed

+50
-31
lines changed

3 files changed

+50
-31
lines changed

.github/workflows/bump_version.py

-4
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,8 @@ def get_release_notes(tag: str = Updater.new_version):
9090
found_notes = True
9191
else:
9292
found_notes = False
93-
elif line.startswith("[unreleased]: ") and found_notes:
94-
found_notes = False
9593
elif found_notes:
9694
buf += line
97-
elif line.startswith(tag_pattern + ": "):
98-
buf += line.replace(tag_pattern, "Full commit diff", 1)
9995
return title.rstrip(), buf.strip()
10096

10197

CHANGELOG.md

+25-6
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,32 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77
<!-- markdownlint-disable MD024 -->
88

9-
## [Unreleased]
9+
## [Unreleased] - 2024-09-21 to present
1010

1111
### <!-- 1 --> 🚀 Added
1212

13-
- Add a change log in [`9bfab31`](https://github.com/cpp-linter/cpp_linter_rs/commit/9bfab318394814d2515f3959f744d60a12d415f1)
13+
- Add changelog and automate version bump and release workflows by @2bndy5 in [#42](https://github.com/cpp-linter/cpp_linter_rs/pull/42)
1414

1515
### <!-- 4 --> 🛠️ Fixed
1616

1717
- Fix typo in node-binding/README by @2bndy5 in [`7732676`](https://github.com/cpp-linter/cpp_linter_rs/commit/7732676e03941a37a4fb5b474d319c640689985a)
1818

19+
### <!-- 6 --> 📦 Dependency updates
20+
21+
- Bump the npm group with 2 updates by @dependabot[bot] in [#43](https://github.com/cpp-linter/cpp_linter_rs/pull/43)
22+
1923
### <!-- 8 --> 📝 Documentation
2024

2125
- Release trial follow up by @2bndy5 in [#41](https://github.com/cpp-linter/cpp_linter_rs/pull/41)
2226

2327
### <!-- 9 --> 🗨️ Changed
2428

2529
- Gimme them badges by @2bndy5 in [`c0f1ea5`](https://github.com/cpp-linter/cpp_linter_rs/commit/c0f1ea516ee6efdf1137884cbc2e99e4ce1d4a11)
30+
- Move logic from py script to jinja template (release CI) in [`bc05419`](https://github.com/cpp-linter/cpp_linter_rs/commit/bc05419920e15704352d344a4fa7da67824cc776)
31+
32+
[Unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD
33+
34+
Full commit diff: [`v2.0.0-rc4...HEAD`][Unreleased]
2635

2736
## [2.0.0-rc4] - 2024-09-21
2837

@@ -34,13 +43,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3443

3544
- Bump version to v2.0.0-rc4 by @2bndy5 in [`3e98e20`](https://github.com/cpp-linter/cpp_linter_rs/commit/3e98e20d2405b909b038ff87911dc0d5457613cc)
3645

46+
[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4
47+
48+
Full commit diff: [`v2.0.0-rc3...v2.0.0-rc4`][2.0.0-rc4]
49+
3750
## [2.0.0-rc3] - 2024-09-21
3851

3952
### <!-- 9 --> 🗨️ Changed
4053

4154
- [node] add life cycle script prepublishOnly by @2bndy5 in [`55650ea`](https://github.com/cpp-linter/cpp_linter_rs/commit/55650ea96aac628023acb120525d674bcf17a529)
4255
- Bump version to v2.0.0-rc3 by @2bndy5 in [`070c5f7`](https://github.com/cpp-linter/cpp_linter_rs/commit/070c5f75f15d0190ee0204992165673c8f16c47d)
4356

57+
[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3
58+
59+
Full commit diff: [`v2.0.0-rc2...v2.0.0-rc3`][2.0.0-rc3]
60+
4461
## [2.0.0-rc2] - 2024-09-21
4562

4663
### <!-- 1 --> 🚀 Added
@@ -58,6 +75,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
5875
- Some cleanup from release trials by @2bndy5 in [`25c3951`](https://github.com/cpp-linter/cpp_linter_rs/commit/25c3951b0ecef9e078ea71932c9401ad8abc2a28)
5976
- Bump version to v2.0.0-rc2 by @2bndy5 in [`ebcb6c4`](https://github.com/cpp-linter/cpp_linter_rs/commit/ebcb6c4941fbaa8147c768252d6d7d9adcfa3bb3)
6077

78+
[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2
79+
80+
Full commit diff: [`v2.0.0-rc1...v2.0.0-rc2`][2.0.0-rc2]
81+
6182
## [2.0.0-rc1] - 2024-09-19
6283

6384
### <!-- 1 --> 🚀 Added
@@ -114,10 +135,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
114135
- Refactor files by @2bndy5 in [#38](https://github.com/cpp-linter/cpp_linter_rs/pull/38)
115136
- Metadata changes by @2bndy5 in [`f4237ae`](https://github.com/cpp-linter/cpp_linter_rs/commit/f4237ae593e468eca0e63169c9360e97bd6e1f26)
116137

117-
[unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD
118-
[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4
119-
[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3
120-
[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2
121138
[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1
122139

140+
Full commit diff: [`2e25fec...v2.0.0-rc1`][2.0.0-rc1]
141+
123142
<!-- generated by git-cliff -->

cliff.toml

+25-21
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ body = """
1717
{%- macro remote_url() -%}
1818
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
1919
{%- endmacro -%}
20+
{%- set UNRELEASED = "Unreleased" -%}
21+
{%- set init_commit = "2e25fec0a447df24d0bcc1b80f6624040bab755e" -%}
22+
{%- set this_version = UNRELEASED -%}
2023
2124
{% if version -%}
22-
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
25+
{%- set this_version = version | trim_start_matches(pat="v") -%}
26+
## [{{ this_version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
2327
{%- if message %}
2428
2529
> {{ message }}
2630
{%- endif %}
2731
{% else -%}
28-
## [Unreleased]
32+
## [{{ UNRELEASED }}] - {{ previous.timestamp | date(format="%Y-%m-%d") }} to present
2933
{% endif -%}
3034
3135
{% for group, commits in commits | group_by(attribute="group") %}
@@ -39,9 +43,25 @@ body = """
3943
[`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }})
4044
{%- endif -%}
4145
{% endfor %}
42-
{% endfor %}
46+
{% endfor -%}
47+
48+
{% set first_commit = previous.version -%}
49+
{%- set last_commit = "HEAD" -%}
50+
{% if version -%}
51+
{%- set last_commit = version -%}
52+
{%- if not previous.version -%}
53+
{#- If this is the first versioned release, use the initial commit -#}
54+
{%- set first_commit = init_commit -%}
55+
{%- endif -%}
56+
{%- endif %}
57+
[{{ this_version }}]: {{ self::remote_url() }}/compare/{{ first_commit }}...{{ last_commit }}
4358
44-
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
59+
Full commit diff: [`{% if previous.version -%}
60+
{{ first_commit }}
61+
{%- else -%}
62+
{{ init_commit | truncate(length=7, end="") }}
63+
{%- endif %}...{{ last_commit }}`][{{ this_version }}]
64+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
4565
## New Contributors
4666
{%- endif -%}
4767
@@ -54,28 +74,12 @@ body = """
5474
"""
5575
# template for the changelog footer
5676
footer = """
57-
{%- macro remote_url() -%}
58-
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
59-
{%- endmacro -%}
60-
61-
{% for release in releases -%}
62-
{% if release.version -%}
63-
{% if release.previous.version -%}
64-
[{{ release.version | trim_start_matches(pat="v") }}]: \
65-
{{ self::remote_url() }}/compare/{{ release.previous.version }}...{{ release.version }}
66-
{% endif -%}
67-
{% else -%}
68-
[unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}...HEAD
69-
{% endif -%}
70-
{% endfor -%}
71-
[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1
72-
7377
<!-- generated by git-cliff -->
7478
"""
7579
# remove the leading and trailing whitespace from the templates
7680
trim = true
7781
# The file path for output. This can be overridden with `--output` CLI arg
78-
output = "CHANGELOG.md"
82+
# output = "CHANGELOG.md"
7983

8084
[git]
8185
# parse the commits based on https://www.conventionalcommits.org

0 commit comments

Comments
 (0)