Closed MetRonnie closed 10 months ago
Ok, I was able to achieve this by making the template like this
{% if sections[""] %}
+{% if "ui-version" in sections[""] %}
+{{ sections[""]["ui-version"].keys()|first }}
+
+{% endif %}
-{% for category, val in definitions.items() if category in sections[""] %}
+{% for category, val in definitions.items() if category in sections[""] and category != "ui-version" %}
### {{ definitions[category]['name'] }}
{% for text, pulls in sections[""][category].items() %}
{{ pulls|join(', ') }} - {{ text }}
{% endfor %}
{% endfor %}
{% else %}
No significant changes.
{% endif %}
And in the CI step it runs
towncrier create +.ui-version.md --content "UI version: ${UI_VERSION}"
Use case: We have a project that bundles a web UI which usually (but not always) gets updated with each release. So we want to include a line saying which UI version is bundled in this version of the project, like this:
The bundled UI version can be got from either the directory name
ui/4.5.6/
or we could create a fragment file for it in our CI process (but it wouldn't know the number of the PR it's creating).If it's not currently possible I think the simplest way to do this would be have a way to include in the Jinja2 template the contents of a custom pseudo-fragment file in the
changes.d
directory.