Skip to content

Commit bc05419

Browse files
committed
move logic from py script to jinja template (release CI)
1 parent afd9198 commit bc05419

File tree

3 files changed

+41
-29
lines changed

3 files changed

+41
-29
lines changed

.github/workflows/bump_version.py

Lines changed: 0 additions & 4 deletions
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

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
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

@@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2424

2525
- Gimme them badges by @2bndy5 in [`c0f1ea5`](https://github.com/cpp-linter/cpp_linter_rs/commit/c0f1ea516ee6efdf1137884cbc2e99e4ce1d4a11)
2626

27+
[Unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD
28+
29+
Full commit diff: [`v2.0.0-rc4...HEAD`][Unreleased]
30+
2731
## [2.0.0-rc4] - 2024-09-21
2832

2933
### <!-- 4 --> 🛠️ Fixed
@@ -34,13 +38,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3438

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

41+
[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4
42+
43+
Full commit diff: [`v2.0.0-rc3...v2.0.0-rc4`][2.0.0-rc4]
44+
3745
## [2.0.0-rc3] - 2024-09-21
3846

3947
### <!-- 9 --> 🗨️ Changed
4048

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

52+
[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3
53+
54+
Full commit diff: [`v2.0.0-rc2...v2.0.0-rc3`][2.0.0-rc3]
55+
4456
## [2.0.0-rc2] - 2024-09-21
4557

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

73+
[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2
74+
75+
Full commit diff: [`v2.0.0-rc1...v2.0.0-rc2`][2.0.0-rc2]
76+
6177
## [2.0.0-rc1] - 2024-09-19
6278

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

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
121133
[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1
122134

135+
Full commit diff: [`2e25fec...v2.0.0-rc1`][2.0.0-rc1]
136+
123137
<!-- generated by git-cliff -->

cliff.toml

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ body = """
1717
{%- macro remote_url() -%}
1818
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
1919
{%- endmacro -%}
20+
{%- set init_commit = "2e25fec0a447df24d0bcc1b80f6624040bab755e" -%}
21+
{%- set this_version = "Unreleased" -%}
2022
2123
{% if version -%}
22-
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
24+
{%- set this_version = version | trim_start_matches(pat="v") -%}
25+
## [{{ this_version }}] - {{ timestamp | date(format="%Y-%m-%d") }}
2326
{%- if message %}
2427
2528
> {{ message }}
@@ -39,9 +42,24 @@ body = """
3942
[`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }})
4043
{%- endif -%}
4144
{% endfor %}
42-
{% endfor %}
45+
{% endfor -%}
46+
47+
{% set first_commit = previous.version -%}
48+
{%- set last_commit = "HEAD" -%}
49+
{% if version -%}
50+
{%- set last_commit = version -%}
51+
{%- if not previous.version -%}
52+
{%- set first_commit = init_commit -%}
53+
{%- endif -%}
54+
{%- endif %}
55+
[{{ this_version }}]: {{ self::remote_url() }}/compare/{{ first_commit }}...{{ last_commit }}
4356
44-
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
57+
Full commit diff: [`{% if previous.version -%}
58+
{{ first_commit }}
59+
{%- else -%}
60+
{{ init_commit | truncate(length=7, end="") }}
61+
{%- endif %}...{{ last_commit }}`][{{ this_version }}]
62+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
4563
## New Contributors
4664
{%- endif -%}
4765
@@ -54,28 +72,12 @@ body = """
5472
"""
5573
# template for the changelog footer
5674
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-
7375
<!-- generated by git-cliff -->
7476
"""
7577
# remove the leading and trailing whitespace from the templates
7678
trim = true
7779
# The file path for output. This can be overridden with `--output` CLI arg
78-
output = "CHANGELOG.md"
80+
# output = "CHANGELOG.md"
7981

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

0 commit comments

Comments
 (0)