feat(changelog): Support remote git repositories as template sources by bilelomrani1 · Pull Request #1404 · python-semantic-release/python-semantic-release
While working on this feature, I noticed a potential limitation worth discussing for a future enhancement.
When using user templates, recursive_render() mirrors the template directory structure directly to the project root. For
example: template_dir/docs/CHANGELOG.md.j2 → ./docs/CHANGELOG.md
With remote template sources, users may want to use a template from an external repository or storage that has its own
directory structure. Currently, they cannot control where the rendered output lands in their project, it's dictated by the
template's internal layout.
Users can already control which part of a remote template to use by pointing template_dir to a specific subdirectory:
template_dir = "git+https://github.com/org/templates@main/changelogs"
But, there's no way to render templates to a location other than the project root. This matters when users want their changelog in a subdirectory like docs/ or build/, or in a more complex location, for instance in a monorepo.
I'm proposing to add a changelog.output_dir config option:
[tool.semantic_release.changelog] template_dir = "git+https://github.com/org/templates@main" output_dir = "docs/"
This would render the template rooted at templates on the remote, inside the docs/ directory locally. Default would be . for backwards compatibility.
I wanted to flag it as a potential follow-up. Happy to hear thoughts on whether this is a use case worth supporting and which approach would fit best with the existing design.