Skip to content

Commit

Permalink
build: filter release notes to useful categories (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-makerx authored Aug 21, 2024
1 parent 297d858 commit 10b76b9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions templates/.macros.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{%- macro render_type_commits(type_commits) -%}
{%- for type_ in ("breaking", "feature", "performance", "fix", "documentation") -%}
{%- if type_ in type_commits %}
### {{ type_ | capitalize }}
{% for commit in type_commits[type_] %}
* {{ commit["descriptions"][0] }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% set ns = namespace(skip_line=false) -%}
{%- for line in commit["descriptions"][1:] -%}
{# skip co-author annotations in commit messages and internal notes #}
{%- if "---------" in line -%}
{%- set ns.skip_line = true -%}
{%- elif not ns.skip_line %}
{{ line | indent(2, first=True, blank=True)}}
{% endif -%}
{%- endfor %}
{%- endfor -%}
{%- endif %}
{%- endfor -%}
{%- endmacro -%}

3 changes: 3 additions & 0 deletions templates/.release_notes.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% import '.macros.j2' as macros -%}
# {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{{ macros.render_type_commits(release["elements"]) }}
10 changes: 10 additions & 0 deletions templates/CHANGELOG.md.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{% import '.macros.j2' as macros -%}
# CHANGELOG
{%- if context.history.unreleased | length > 0 %}
## Unreleased
{{ macros.render_type_commits(context.history.unreleased) }}
{%- endif %}
{%- for version, release in context.history.released.items() %}
## {{ version.as_semver_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{{ macros.render_type_commits(release["elements"]) }}
{%- endfor %}

0 comments on commit 10b76b9

Please sign in to comment.