Closed
Labels
Description
Question
In a monorepo with structure like:
./
- src/: shared code
- projects
- api/
- pyproject.toml
- src/
- <other packages>
- ...
I’d like any change in src/ to be reflected as a change of the package in projects/api by setting path_filters like:
[tool.semantic_release.commit_parser_options]
path_filters = [".", "../../src"]
But modifications in src/ don’t get added to the generated changelog:
touch src/test.txt
git add .
git commit -m "fix: test"
cd projects/api
semantic-release -v --noop version
Should I not rely on path filters to include such changes in code shared by multiple packages ?
Configuration
Semantic Release Configuration
[tool.semantic_release]
commit_parser = "conventional-monorepo"
commit_message = """\
chore(release): api@{version}`
Automatically generated by python-semantic-release
"""
tag_format = "api-v{version}"
version_toml = ["pyproject.toml:project.version"]
build_command = """
uv lock --upgrade-package "$PACKAGE_NAME"
git add ../../uv.lock
"""
[tool.semantic_release.commit_parser_options]
path_filters = [".", "../../src"]
scope_prefix = "api-"
[tool.semantic_release.changelog]
# Recommended patterns for conventional commits parser that is scope aware
exclude_commit_patterns = [
'''^chore(?:\([^)]*?\))?: .+''',
'''^ci(?:\([^)]*?\))?: .+''',
'''^refactor(?:\([^)]*?\))?: .+''',
'''^style(?:\([^)]*?\))?: .+''',
'''^test(?:\([^)]*?\))?: .+''',
'''^build\((?!deps\): .+)''',
'''^Initial [Cc]ommit.*''',
]
mode = "update"
insertion_flag = "<!-- python-semantic-release insertion_flag -->"
[tool.semantic_release.changelog.default_templates]
changelog_file = "../../docs/api/changelog.md"
output_format = "md"
Additional context
git log --oneline --decorate --graph --all -n 50
Activity
guillaumecherel commentedon Nov 25, 2025
I tried writing a PR but couldn’t get far enough to test it. I hope it can help anyway otherwise just discard it.
codejedi365 commentedon Nov 25, 2025
Yes, path filters does work outside of the package where it is defined. It is important to make sure that the current working directory is where your configuration is so that the file paths are resolved properly.
See my example repository,
codejedi365/psr-monorepo-poweralpha, where the documentation is tracked outside of the package directory.guillaumecherel commentedon Nov 25, 2025
Thanks!
I did take care of moving into the same directory as the package.
I experimented with your example repository. I noticed that it uses a custom commit parser directly included in the repository. I tried using the builtin
conventional-monorepoinstead and that reproduced my issue. Here are steps to reproduce.Let’s add a file in a directory that is tracked by
path_filtersin the current pyproject.toml, and commit it:The output ends with the changelog containig the latest commit as expected:
Now edit pyproject.toml to replace
with
and re-run
Now the output is:
It looks like the latest commit was not selected for the next release.
codejedi365 commentedon Nov 26, 2025
Well that's odd. Will have to look into it further. There is not much difference between the two as I wrote the custom parser first and then published it as
conventional-monorepowith very little refactoring.guillaumecherel commentedon Dec 1, 2025
I think I’ve figured it out and my PR was not the right fix.
I realized that the pydantic field validators for path_filters weren’t being executed:
python-semantic-release/src/semantic_release/commit_parser/conventional/options_monorepo.py
Line 62 in 2dd8be7
and
python-semantic-release/src/semantic_release/commit_parser/conventional/options_monorepo.py
Line 62 in 2dd8be7
When I swapped the
@classmethodand@field_validatordecorators everywhere to make sure the latter is applied on top of the former, they get executed.Then I got validation errors because the validators return Paths but your type annotations expect strings:
python-semantic-release/src/semantic_release/commit_parser/conventional/options_monorepo.py
Line 26 in 2dd8be7
Finally, after changing str to Path, I had to make a small change in the parser to work with paths rather than strings.
Everything seems alright now. I’m updating my PR
fix(parser-conventional-monorepo): fix parser opts validator for outs…
fix(parser-conventional-monorepo): fix parser opts validator for outs…
[-]Can path_filters reference paths outside the current package subtree ?[/-][+][bug] Monorepo `path_filters` fails to reference paths outside the current package subtree[/+]codejedi365 commentedon Dec 14, 2025
🎉 This issue has been resolved in v10.5.3 🎉
You can find more information about this release on the GitHub Releases page.
If your issue persists, please reply here and we will re-open the issue. If you receive a new error, please open a new issue and reference this issue there.