- Notifications
You must be signed in to change notification settings - Fork261
Description
Description
Adding theuse_only_cwd_commits config makes it possible to make the semantic release look for commits in thecwd folder only.
The default behavior is any commit in the repo can trigger a package release.
_repo:Optional[Repo]_sub_directory=""try:_repo=Repo(".",search_parent_directories=True)ifconfig.get("use_only_cwd_commits")andconfig.get("version_source")=="commit":_sub_directory=os.path.relpath(os.getcwd(),_repo.working_dir)exceptInvalidGitRepositoryError:_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 useuse_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.tomlIn this example,app1 referenceslib1 as a local dependency using the Poetry path referencehttps://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 thelib1 it should trigger theapp1 release, however, the commit path is only in thelibs/lib1 folder, not in theapps/app1 folder.
In this case, theuse_only_cwd_commits config isn't gonna work.
If we have the option to specify multiple paths for the commit analyzer, I could explicitly referencelibs/lib1 in theapps/app1/pyproject.toml semantic release config.
Possible implementation
- a new config entry
commit_pathsthat accepts a list of paths.
[tool.semantic_release]version_variable = ["pyproject.toml:version"]branch ="main"upload_to_pypi =falseupload_to_release =falsecommit_paths = ["apps/app1","libs/lib1"]