Title: feat: Commit parser w/ path filter for monorepos · Issue #614 · python-semantic-release/python-semantic-release · GitHub
Open Graph Title: feat: Commit parser w/ path filter for monorepos · Issue #614 · python-semantic-release/python-semantic-release
X Title: feat: Commit parser w/ path filter for monorepos · Issue #614 · python-semantic-release/python-semantic-release
Description: 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/p...
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python-semantic-release/python-semantic-release/issues/614
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"feat: Commit parser w/ path filter for monorepos","articleBody":"## Description\r\n\r\nAdding the `use_only_cwd_commits` config makes it possible to make the semantic release look for commits in the `cwd` folder only.\r\n\r\nThe default behavior is any commit in the repo can trigger a package release.\r\n\r\nhttps://github.com/python-semantic-release/python-semantic-release/blob/master/semantic_release/vcs_helpers.py#L19-L26\r\n```python\r\n_repo: Optional[Repo]\r\n_sub_directory = \"\"\r\ntry:\r\n _repo = Repo(\".\", search_parent_directories=True)\r\n if config.get(\"use_only_cwd_commits\") and config.get(\"version_source\") == \"commit\":\r\n _sub_directory = os.path.relpath(os.getcwd(), _repo.working_dir)\r\nexcept InvalidGitRepositoryError:\r\n _repo = None\r\n```\r\n\r\nit will be good to have a config option to define one or more folders in the repo to semantic release CLI look for commits.\r\n\r\n## Use cases\r\n\r\n**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.\r\n\r\nHowever, 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.\r\n\r\nIssue reference: https://github.com/lucasvieirasilva/nx-plugins/issues/122\r\n\r\nExample:\r\n\r\n```text\r\n- apps/app1/pyproject.toml\r\n- libs/lib1/pyproject.toml\r\n```\r\n\r\nIn this example, `app1` references `lib1` as a local dependency using the Poetry path reference https://python-poetry.org/docs/dependency-specification/#path-dependencies\r\n\r\n```toml\r\n...\r\n[tool.poetry]\r\nname = \"app1\"\r\n...\r\n\r\n [tool.poetry.dependencies.lib1]\r\n path = \"../../libs/lib1\"\r\n develop = true\r\n...\r\n```\r\n\r\nIf 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.\r\n\r\nIn this case, the `use_only_cwd_commits` config isn't gonna work.\r\n\r\n 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.\r\n\r\n## Possible implementation\r\n\r\n- a new config entry `commit_paths` that accepts a list of paths.\r\n\r\n```toml\r\n[tool.semantic_release]\r\nversion_variable = [\r\n \"pyproject.toml:version\"\r\n]\r\nbranch = \"main\"\r\nupload_to_pypi = false\r\nupload_to_release = false\r\ncommit_paths = [\r\n \"apps/app1\",\r\n \"libs/lib1\"\r\n]\r\n```\r\n\r\n","author":{"url":"https://github.com/lucasvieirasilva","@type":"Person","name":"lucasvieirasilva"},"datePublished":"2023-06-26T14:32:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/614/python-semantic-release/issues/614"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ffb15f0c-e404-4d43-0eae-7d58c66cff03 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 873E:1B4AFD:12DC45D:1832D31:6990D2EF |
| html-safe-nonce | 2fbf4e3c645422683e9e1ea428f64ee51b04912b6a8311c080a8b6f419f9e63f |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzNFOjFCNEFGRDoxMkRDNDVEOjE4MzJEMzE6Njk5MEQyRUYiLCJ2aXNpdG9yX2lkIjoiODgwMjI2MDM1NjQ5Nzk4NjI4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 672bba8de9c6bc51c25d147d8cbc31e516b380a6a7321d9ea55494063303d96d |
| hovercard-subject-tag | issue:1774938270 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python-semantic-release/python-semantic-release/614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ed7f03be50360097807304d32e8b8c549ad08bd37bb0c89b8ce0a85079eca2fb/python-semantic-release/python-semantic-release/issues/614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ed7f03be50360097807304d32e8b8c549ad08bd37bb0c89b8ce0a85079eca2fb/python-semantic-release/python-semantic-release/issues/614 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | lucasvieirasilva |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/python-semantic-release/python-semantic-release git https://github.com/python-semantic-release/python-semantic-release.git |
| octolytics-dimension-user_id | 116517554 |
| octolytics-dimension-user_login | python-semantic-release |
| octolytics-dimension-repository_id | 39765732 |
| octolytics-dimension-repository_nwo | python-semantic-release/python-semantic-release |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 39765732 |
| octolytics-dimension-repository_network_root_nwo | python-semantic-release/python-semantic-release |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 848bc6032dcc93a9a7301dcc3f379a72ba13b96e |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width