Skip to content

Commit

Permalink
build: improve changelog output
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-makerx committed Mar 28, 2024
1 parent e5446db commit 9d87eae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ prerelease = true
[tool.semantic_release.commit_parser_options]
allowed_tags = ["build", "chore", "ci", "docs", "feat", "fix", "perf", "style", "refactor", "test"]
minor_tags = ["feat"]
patch_tags = ["fix", "perf"]
patch_tags = ["fix", "perf", "docs"]

[tool.semantic_release.publish]
dist_glob_patterns = ["dist/*", "stubs/dist/*"] # order here is important to ensure compiler wheel is published first
Expand Down
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 skip_line = false -%}
{%- for line in commit["descriptions"][1:] -%}
{# skip co-author annotations in commit messages #}
{%- if "Co-authored-by:" in line -%}
{%- set skip_line = true -%}
{%- elif not skip_line %}
{{ line | indent(2, first=True, blank=True)}}
{% endif -%}
{%- endfor %}
{%- endfor -%}
{%- endif %}
{%- endfor -%}
{%- endmacro -%}

7 changes: 2 additions & 5 deletions templates/.release_notes.md.j2
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{% import '.macros.j2' as macros -%}
# {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{% for type_, commits in release["elements"] | dictsort %}{% if type_ in ("feature", "fix", "performance") %}
## {{ type_ | capitalize }}
{% for commit in commits %}
* {{ commit["descriptions"][0] | indent(2)}} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endfor %}{% endif %}{% endfor %}
{{ macros.render_type_commits(release["elements"]) }}
21 changes: 6 additions & 15 deletions templates/CHANGELOG.md.j2
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
{% import '.macros.j2' as macros -%}
# CHANGELOG
{% if context.history.unreleased | length > 0 %}
{# UNRELEASED #}
{%- if context.history.unreleased | length > 0 %}
## Unreleased
{% for type_, commits in context.history.unreleased | dictsort %}
{%- if type_ in ("feature", "fix", "performance") %}
### {{ type_ | capitalize }}
{% for commit in commits -%}
* {{ commit["descriptions"][0].strip() | indent(2) }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endfor %}{% endif %}{% endfor %}{% endif %}
{{ macros.render_type_commits(context.history.unreleased) }}
{%- endif %}
{%- for version, release in context.history.released.items() %}
{# RELEASED #}
## {{ version.as_semver_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})
{% for type_, commits in release["elements"] | dictsort %}
{%- if type_ in ("feature", "fix", "performance") %}
### {{ type_ | capitalize }}
{% for commit in commits %}
* {{ commit["descriptions"][0].strip() | indent(2) }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endfor %}{% endif %}{% endfor %}{% endfor %}
{{ macros.render_type_commits(release["elements"]) }}
{% endfor %}

0 comments on commit 9d87eae

Please sign in to comment.