From bc05419920e15704352d344a4fa7da67824cc776 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 24 Sep 2024 20:32:53 -0700 Subject: [PATCH 1/2] move logic from py script to jinja template (release CI) --- .github/workflows/bump_version.py | 4 --- CHANGELOG.md | 24 ++++++++++++++---- cliff.toml | 42 ++++++++++++++++--------------- 3 files changed, 41 insertions(+), 29 deletions(-) diff --git a/.github/workflows/bump_version.py b/.github/workflows/bump_version.py index 5d937d9..523cae8 100644 --- a/.github/workflows/bump_version.py +++ b/.github/workflows/bump_version.py @@ -90,12 +90,8 @@ def get_release_notes(tag: str = Updater.new_version): found_notes = True else: found_notes = False - elif line.startswith("[unreleased]: ") and found_notes: - found_notes = False elif found_notes: buf += line - elif line.startswith(tag_pattern + ": "): - buf += line.replace(tag_pattern, "Full commit diff", 1) return title.rstrip(), buf.strip() diff --git a/CHANGELOG.md b/CHANGELOG.md index d5791bf..96bb564 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 🚀 Added -- Add a change log in [`9bfab31`](https://github.com/cpp-linter/cpp_linter_rs/commit/9bfab318394814d2515f3959f744d60a12d415f1) +- Add changelog and automate version bump and release workflows by @2bndy5 in [#42](https://github.com/cpp-linter/cpp_linter_rs/pull/42) ### 🛠️ Fixed @@ -24,6 +24,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Gimme them badges by @2bndy5 in [`c0f1ea5`](https://github.com/cpp-linter/cpp_linter_rs/commit/c0f1ea516ee6efdf1137884cbc2e99e4ce1d4a11) +[Unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD + +Full commit diff: [`v2.0.0-rc4...HEAD`][Unreleased] + ## [2.0.0-rc4] - 2024-09-21 ### 🛠️ Fixed @@ -34,6 +38,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Bump version to v2.0.0-rc4 by @2bndy5 in [`3e98e20`](https://github.com/cpp-linter/cpp_linter_rs/commit/3e98e20d2405b909b038ff87911dc0d5457613cc) +[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4 + +Full commit diff: [`v2.0.0-rc3...v2.0.0-rc4`][2.0.0-rc4] + ## [2.0.0-rc3] - 2024-09-21 ### 🗨️ Changed @@ -41,6 +49,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [node] add life cycle script prepublishOnly by @2bndy5 in [`55650ea`](https://github.com/cpp-linter/cpp_linter_rs/commit/55650ea96aac628023acb120525d674bcf17a529) - Bump version to v2.0.0-rc3 by @2bndy5 in [`070c5f7`](https://github.com/cpp-linter/cpp_linter_rs/commit/070c5f75f15d0190ee0204992165673c8f16c47d) +[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3 + +Full commit diff: [`v2.0.0-rc2...v2.0.0-rc3`][2.0.0-rc3] + ## [2.0.0-rc2] - 2024-09-21 ### 🚀 Added @@ -58,6 +70,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Some cleanup from release trials by @2bndy5 in [`25c3951`](https://github.com/cpp-linter/cpp_linter_rs/commit/25c3951b0ecef9e078ea71932c9401ad8abc2a28) - Bump version to v2.0.0-rc2 by @2bndy5 in [`ebcb6c4`](https://github.com/cpp-linter/cpp_linter_rs/commit/ebcb6c4941fbaa8147c768252d6d7d9adcfa3bb3) +[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2 + +Full commit diff: [`v2.0.0-rc1...v2.0.0-rc2`][2.0.0-rc2] + ## [2.0.0-rc1] - 2024-09-19 ### 🚀 Added @@ -114,10 +130,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Refactor files by @2bndy5 in [#38](https://github.com/cpp-linter/cpp_linter_rs/pull/38) - Metadata changes by @2bndy5 in [`f4237ae`](https://github.com/cpp-linter/cpp_linter_rs/commit/f4237ae593e468eca0e63169c9360e97bd6e1f26) -[unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD -[2.0.0-rc4]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc3...v2.0.0-rc4 -[2.0.0-rc3]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc2...v2.0.0-rc3 -[2.0.0-rc2]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc1...v2.0.0-rc2 [2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1 +Full commit diff: [`2e25fec...v2.0.0-rc1`][2.0.0-rc1] + diff --git a/cliff.toml b/cliff.toml index 85eb084..ad2489b 100644 --- a/cliff.toml +++ b/cliff.toml @@ -17,9 +17,12 @@ body = """ {%- macro remote_url() -%} https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} {%- endmacro -%} +{%- set init_commit = "2e25fec0a447df24d0bcc1b80f6624040bab755e" -%} +{%- set this_version = "Unreleased" -%} {% if version -%} - ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} + {%- set this_version = version | trim_start_matches(pat="v") -%} + ## [{{ this_version }}] - {{ timestamp | date(format="%Y-%m-%d") }} {%- if message %} > {{ message }} @@ -39,9 +42,24 @@ body = """ [`{{ commit.id | truncate(length=7, end="") }}`]({{ self::remote_url() }}/commit/{{commit.id }}) {%- endif -%} {% endfor %} -{% endfor %} +{% endfor -%} + +{% set first_commit = previous.version -%} +{%- set last_commit = "HEAD" -%} +{% if version -%} + {%- set last_commit = version -%} + {%- if not previous.version -%} + {%- set first_commit = init_commit -%} + {%- endif -%} +{%- endif %} +[{{ this_version }}]: {{ self::remote_url() }}/compare/{{ first_commit }}...{{ last_commit }} -{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} +Full commit diff: [`{% if previous.version -%} + {{ first_commit }} +{%- else -%} + {{ init_commit | truncate(length=7, end="") }} +{%- endif %}...{{ last_commit }}`][{{ this_version }}] +{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %} ## New Contributors {%- endif -%} @@ -54,28 +72,12 @@ body = """ """ # template for the changelog footer footer = """ -{%- macro remote_url() -%} - https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} -{%- endmacro -%} - -{% for release in releases -%} - {% if release.version -%} - {% if release.previous.version -%} - [{{ release.version | trim_start_matches(pat="v") }}]: \ - {{ self::remote_url() }}/compare/{{ release.previous.version }}...{{ release.version }} - {% endif -%} - {% else -%} - [unreleased]: {{ self::remote_url() }}/compare/{{ release.previous.version }}...HEAD - {% endif -%} -{% endfor -%} -[2.0.0-rc1]: https://github.com/cpp-linter/cpp_linter_rs/compare/2e25fec0a447df24d0bcc1b80f6624040bab755e...v2.0.0-rc1 - """ # remove the leading and trailing whitespace from the templates trim = true # The file path for output. This can be overridden with `--output` CLI arg -output = "CHANGELOG.md" +# output = "CHANGELOG.md" [git] # parse the commits based on https://www.conventionalcommits.org From 521809469ebe2803a91084b1e71265fc7e4974a9 Mon Sep 17 00:00:00 2001 From: Brendan <2bndy5@gmail.com> Date: Tue, 24 Sep 2024 20:52:39 -0700 Subject: [PATCH 2/2] add some advice from AI review --- CHANGELOG.md | 7 ++++++- cliff.toml | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 96bb564..9098c53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased] +## [Unreleased] - 2024-09-21 to present ### 🚀 Added @@ -16,6 +16,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix typo in node-binding/README by @2bndy5 in [`7732676`](https://github.com/cpp-linter/cpp_linter_rs/commit/7732676e03941a37a4fb5b474d319c640689985a) +### 📦 Dependency updates + +- Bump the npm group with 2 updates by @dependabot[bot] in [#43](https://github.com/cpp-linter/cpp_linter_rs/pull/43) + ### 📝 Documentation - Release trial follow up by @2bndy5 in [#41](https://github.com/cpp-linter/cpp_linter_rs/pull/41) @@ -23,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### 🗨️ Changed - Gimme them badges by @2bndy5 in [`c0f1ea5`](https://github.com/cpp-linter/cpp_linter_rs/commit/c0f1ea516ee6efdf1137884cbc2e99e4ce1d4a11) +- Move logic from py script to jinja template (release CI) in [`bc05419`](https://github.com/cpp-linter/cpp_linter_rs/commit/bc05419920e15704352d344a4fa7da67824cc776) [Unreleased]: https://github.com/cpp-linter/cpp_linter_rs/compare/v2.0.0-rc4...HEAD diff --git a/cliff.toml b/cliff.toml index ad2489b..71dff74 100644 --- a/cliff.toml +++ b/cliff.toml @@ -17,8 +17,9 @@ body = """ {%- macro remote_url() -%} https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} {%- endmacro -%} +{%- set UNRELEASED = "Unreleased" -%} {%- set init_commit = "2e25fec0a447df24d0bcc1b80f6624040bab755e" -%} -{%- set this_version = "Unreleased" -%} +{%- set this_version = UNRELEASED -%} {% if version -%} {%- set this_version = version | trim_start_matches(pat="v") -%} @@ -28,7 +29,7 @@ body = """ > {{ message }} {%- endif %} {% else -%} - ## [Unreleased] + ## [{{ UNRELEASED }}] - {{ previous.timestamp | date(format="%Y-%m-%d") }} to present {% endif -%} {% for group, commits in commits | group_by(attribute="group") %} @@ -49,6 +50,7 @@ body = """ {% if version -%} {%- set last_commit = version -%} {%- if not previous.version -%} + {#- If this is the first versioned release, use the initial commit -#} {%- set first_commit = init_commit -%} {%- endif -%} {%- endif %}