fix(changelog): support custom Jinja extensions in release notes templates by bilelomrani1 · Pull Request #1405 · python-semantic-release/python-semantic-release
Purpose
Closes #1402
Custom Jinja extensions configured via [tool.semantic_release.changelog.environment] were only available in changelog templates, but not in release notes templates.
This PR applies the same changelog.environment configuration when rendering custom release notes templates.
Rationale
The generate_release_notes() function was creating a separate, non-configurable Jinja environment that ignored user settings. This was inconsistent with how write_changelog_files() handles custom templates.
The fix follows the same pattern used for changelog templates:
- if custom template exists, use the user's configured
template_environment - otherwise use a plain default environment to ensure compatibility
How did you test?
test_release_notes_uses_custom_jinja_extension: Verifies custom Jinja extensions with filters are available in release notes templates. All existing release notes tests continue to pass.
How to Verify
-
Configure a custom Jinja extension in
pyproject.toml:[tool.semantic_release.changelog.environment] extensions = ["my_package.ext:MyCustomExtension"]
-
Create a custom
.release_notes.md.j2template using a filter from the extension:{{ "text" | my_custom_filter }} -
Run
semantic-release changelog --post-to-release-tag <tag>orsemantic-release version -
Verify the release notes render correctly with the custom filter applied
PR Completion Checklist
-
Reviewed & followed the Contributor Guidelines
-
Changes Implemented & Validation pipeline succeeds
-
Commits follow the Conventional Commits standard
and are separated into the proper commit type and scope (recommended order: test, build, feat/fix, docs) -
Appropriate Unit tests added/updated
-
Appropriate End-to-End tests added/updated
-
Appropriate Documentation added/updated and syntax validated for sphinx build (see Contributor Guidelines)