Skip to content

feat: Commit parser w/ path filter for monorepos #614

Closed

Description

@lucasvieirasilva

Description

Adding the use_only_cwd_commits config makes it possible to make the semantic release look for commits in the cwd folder only.

The default behavior is any commit in the repo can trigger a package release.

https://github.com/python-semantic-release/python-semantic-release/blob/master/semantic_release/vcs_helpers.py#L19-L26

_repo: Optional[Repo]
_sub_directory = ""
try:
    _repo = Repo(".", search_parent_directories=True)
    if config.get("use_only_cwd_commits") and config.get("version_source") == "commit":
        _sub_directory = os.path.relpath(os.getcwd(), _repo.working_dir)
except InvalidGitRepositoryError:
    _repo = None

it will be good to have a config option to define one or more folders in the repo to semantic release CLI look for commits.

Use cases

Monorepo: When you have multiple packages in the same repo, you can use use_only_cwd_commits to force the semantic release to look for commits only in the package folder.

However, when you have local dependencies that could potentially trigger the release of the application, it is required to look at multiple folders to decide if a release is necessary.

Issue reference: lucasvieirasilva/nx-plugins#122

Example:

- apps/app1/pyproject.toml
- libs/lib1/pyproject.toml

In this example, app1 references lib1 as a local dependency using the Poetry path reference https://python-poetry.org/docs/dependency-specification/#path-dependencies

...
[tool.poetry]
name = "app1"
...

    [tool.poetry.dependencies.lib1]
    path = "../../libs/lib1"
    develop = true
...

If something changes in the lib1 it should trigger the app1 release, however, the commit path is only in the libs/lib1 folder, not in the apps/app1 folder.

In this case, the use_only_cwd_commits config isn't gonna work.

If we have the option to specify multiple paths for the commit analyzer, I could explicitly reference libs/lib1 in the apps/app1/pyproject.toml semantic release config.

Possible implementation

  • a new config entry commit_paths that accepts a list of paths.
[tool.semantic_release]
version_variable = [
    "pyproject.toml:version"
]
branch = "main"
upload_to_pypi = false
upload_to_release = false
commit_paths = [
    "apps/app1",
    "libs/lib1"
]

Activity

  1. added
    confirmedPrevent from becoming stale
    and removed on Mar 29, 2024
  2. added this to the Monorepo support milestone on Mar 30, 2024
  3. added
    confirmedPrevent from becoming stale
    and removed on Oct 3, 2024
  4. changed the title [-]Filter Paths Commits Analyzer[/-] [+]feat: Commit parser w/ path filter for monorepos[/+] on Oct 3, 2024
  5. 23 remaining items

  6. added 10 commits that reference this issue on Sep 2, 2025
    63011c8
    e74a947
    336b80e
    7fb3dc2
    d7f46fc
    05943e8
    59f5d81
    cfd6f3c
    0de5702
    93c2b1f
  7. added a commit that references this issue on Sep 8, 2025
    e18f866
  8. codejedi365 commented on Sep 8, 2025

    @codejedi365
    Contributor

    🎉 This issue has been resolved in v10.4.0 🎉

    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 ticket. If you receive a new error, please open a new issue and reference this ticket there.

  9. added and removed
    confirmedPrevent from becoming stale
    on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureA new feature or a feature requestreleased

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions