Skip to content

fix(changelog): support custom Jinja extensions in release notes templates#1405

Open
bilelomrani1 wants to merge 2 commits intopython-semantic-release:masterfrom
bilelomrani1:fix/release-notes-custom-extensions
Open

fix(changelog): support custom Jinja extensions in release notes templates#1405
bilelomrani1 wants to merge 2 commits intopython-semantic-release:masterfrom
bilelomrani1:fix/release-notes-custom-extensions

Conversation

@bilelomrani1
Copy link

@bilelomrani1 bilelomrani1 commented Jan 2, 2026

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

  1. Configure a custom Jinja extension in pyproject.toml:

    [tool.semantic_release.changelog.environment]
    extensions = ["my_package.ext:MyCustomExtension"]
  2. Create a custom .release_notes.md.j2 template using a filter from the extension:

    {{ "text" | my_custom_filter }}
  3. Run semantic-release changelog --post-to-release-tag <tag> or semantic-release version

  4. 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)

@bilelomrani1
Copy link
Author

Just a note: this is a small fix to support custom Jinja extensions in release notes templates. It's self-contained and shouldn't conflict with the v11 refactoring work.

See #1407 for the broader context on my use case. Happy to address any feedback whenever you have time to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support custom Jinja extensions in release notes templates

1 participant