Skip to content

Move logic for release notes generation from Python script to Jinja template (release CI) #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/workflows/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
31 changes: 25 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,32 @@ 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).
<!-- markdownlint-disable MD024 -->

## [Unreleased]
## [Unreleased] - 2024-09-21 to present

### <!-- 1 --> 🚀 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)

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

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

### <!-- 6 --> 📦 Dependency updates

- Bump the npm group with 2 updates by @dependabot[bot] in [#43](https://github.com/cpp-linter/cpp_linter_rs/pull/43)

### <!-- 8 --> 📝 Documentation

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

### <!-- 9 --> 🗨️ 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

Full commit diff: [`v2.0.0-rc4...HEAD`][Unreleased]

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

Expand All @@ -34,13 +43,21 @@ 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

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

- [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

### <!-- 1 --> 🚀 Added
Expand All @@ -58,6 +75,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

### <!-- 1 --> 🚀 Added
Expand Down Expand Up @@ -114,10 +135,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]

<!-- generated by git-cliff -->
46 changes: 25 additions & 21 deletions cliff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,19 @@ 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 -%}

{% 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 }}
{%- endif %}
{% else -%}
## [Unreleased]
## [{{ UNRELEASED }}] - {{ previous.timestamp | date(format="%Y-%m-%d") }} to present
{% endif -%}

{% for group, commits in commits | group_by(attribute="group") %}
Expand All @@ -39,9 +43,25 @@ 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 -%}
{#- If this is the first versioned release, use the initial commit -#}
{%- 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 -%}

Expand All @@ -54,28 +74,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

<!-- generated by git-cliff -->
"""
# 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
Expand Down