diff --git a/templates/.macros.j2 b/templates/.macros.j2 new file mode 100644 index 00000000..7a2cf4e5 --- /dev/null +++ b/templates/.macros.j2 @@ -0,0 +1,23 @@ +{% macro render_single_commit(commit) -%} +* {% if commit["scope"] is not none %}**{{ commit["scope"] }}** {% endif %}{{ commit["descriptions"][0].rstrip() }} ([`{{commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }})) +{% for line in commit["descriptions"][1:] %} +{{ line | indent(2, first=True, blank=True) -}} +{% endfor %} +{%- endmacro %} + +{% macro render_unknown_commit(commit) -%} +* {{ commit.message.rstrip().split("\n")[0] }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }})) +{% for line in commit.message.rstrip().split("\n")[1:] %} +{{ line | indent(2, first=True, blank=True) -}} +{% endfor %} +{%- endmacro %} + +{%- macro render_elements(elements) -%} +{% for type_, commits in elements | dictsort %} +### {{ type_ | capitalize }} +{% for commit in commits -%}{% if type_ != "unknown" %} +{{ render_single_commit(commit).rstrip() }} +{% else %} +{{ render_unknown_commit(commit).rstrip() }} +{% endif %}{%- endfor %}{% endfor %} +{%- endmacro -%} diff --git a/templates/.release_notes.md.j2 b/templates/.release_notes.md.j2 new file mode 100644 index 00000000..94970ae7 --- /dev/null +++ b/templates/.release_notes.md.j2 @@ -0,0 +1,3 @@ +{% import ".macros.j2" as macros -%} +# {{ version.as_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }}) +{{ macros.render_elements(release["elements"]) }} diff --git a/templates/CHANGELOG.md.j2 b/templates/CHANGELOG.md.j2 new file mode 100644 index 00000000..b6089863 --- /dev/null +++ b/templates/CHANGELOG.md.j2 @@ -0,0 +1,12 @@ +# CHANGELOG +{% import ".macros.j2" as macros -%} +{% if context.history.unreleased | length > 0 %} +{# UNRELEASED #} +## Unreleased +{{ macros.render_elements(context.history.unreleased) -}} +{% endif %} +{% for version, release in context.history.released.items() %} +{# RELEASED #} +## {{ version.as_semver_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }}) +{{ macros.render_elements(release["elements"]) -}} +{% endfor %}