-
Notifications
You must be signed in to change notification settings - Fork 255
Improve support for monorepo using Conventional Commits scope #1215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You should try out PR #1143, I haven't published it yet as it doesn't have automated testing but I have done significant testing with it on a monorepo example, https://github.com/codejedi365/psr-monorepo-poweralpha. There is more improvements to make to the PR as I need to make squash commits available but this is a starting point. It isolates file paths and also allows for scope differentiated commits to create tags per submodule in the monorepo. |
I'll take a look, wondering if a full parser is required, I just filtered commits based on scopes, which affected both release and changelog, Is there any good reason for a new parser? Thanks, Asaf |
Yes because I'm solving more than just your request for scope delineation. #614 request is more encompassing and my implementation includes scope as an additional filter. Also I have other plans for the regular parsers to include scopes later but given the complexities of monorepos it's best to be separate. Monorepos tend to have multiple tag formats and I expect more issues in the future. |
I see your point, I'm trying using to the new parser and I have some feedbacks: Scope should be optionalIf conventional commits defines the structure of So I would love to see the parser supports commit messages such as Another thing is that a root project is common in workspaces, so the main I think the best way would be to use patterns rather scopes, that requires two props:
That way it's possible to define the root project such: [tool.semantic_release.commit_parser_options]
scope_pattern = '(?!(?:srvc1|srvc2)(?:-|(?=\))))[\w-]+'
scope_optional = true And in the packages: [tool.semantic_release.commit_parser_options]
scope_pattern = 'srvsvc1(?:-[\w-]+)?'
scope_optional = false Initial tests are working pretty well. Changelog locationsThe scripts are a bit tricky having I couldn't find a way to rename the changelog.md the CHANGELOG.md and make sure it's generated inside the packages instead of a separated folder. I would love to get some guidelines how to do that. Best, |
Firstly, it is important to note sphinx-autobuild documentation/docs documentation/docs/_build/html --open-browser
# this is notional as everything is in markdown and without a
# plugin/translator sphinx does not support markdown Under the documentation/docs folder he would have a per service folder of documentation. If I remember correctly, he wanted some customized changelog templates or customized release notes which caused us to need a custom templates directory. If he didn't need it customized, then I think we could of just defined the setting
No, this is valid and proper defensive bash programming technique. I recommend looking into ShellCheck as it is a bash linting tool and it has a rule to recommend that all change directory commands should abort the script if a change directory fails.
If you want it generated inside the packages then just remove the |
Uh, I thought the current changelog would not be sufficient in case of a monorepo and that's your minimal repo for the parser demonstration, fair enough, for a minimal example I will clean this up so others can have a simple reference. |
You are expecting things that are not produced or published yet. This is why PSR does not officially support monorepos. I gave you an example of what I have at this point. Their monorepo was complex and kept getting more complex as I provided an example and then had to re-design it. If you want to provide a recommendation of a simpler monorepo, then I would appreciate it. The nuance of your repo design is the inclusion of a top level |
Ye I get it :), thanks for the quick response, I appreciate it! I'm working on a blog post about how to release a uv workspace with PSR and I'll link it here for future reference. Thanks. |
Thanks @asaf for taking the time to provide feedback.
I disagree with your concept here. Monorepos are not defined in the conventional-commits spec so stating which service its related to is still a provided scope. Secondly, the parser I recommended filters by file paths as the primary mechanism and the scope is secondary. You can still provide no scope and as long as the files are in the correct module then it will be selected for the changelog. The real magic is for changes to files outside of the submodule that are still relevant to the project then you can specify it via the scope prefix. In this case, it is my opinion that you should also specify a deeper scope of what external file/process is affecting the version bump of the submodule.
Although conceptually this makes sense, I haven't seen python actually able to support a top level project with submodules. I have considered a top level configuration rather than the expectation of multiple configurations within each submodule but that is a ways off. If you had a top level Will have to reconsider top level releasing once I have an example of it.
Glad to hear that. |
sounds good. |
I had to add IMO regarding the package scopes :) I think it's reasonable to have simple typed commits for a scoped package. it clarifies which commit belongs to which package. I think my primary misunderstanding here is that I thought filtering is all about scopes. If filtering is primarily done by files (that also justifies a full parser rather the PR I've sent for a filter by scope) then removing the prefix will do for me.
I think |
This issue has not received a response in 14 days. If no response is received in 7 days, it will be closed. We look forward to hearing from you. |
This issue was closed because no response was received. |
Feature Request
Description
Currently, Python Semantic Release does not support filtering commits by scopes (
(pkg1)
,(pkg2)
) in monorepos. This means that when multiple packages exist in a single repository, version bumps may happen incorrectly.For example, given a monorepo with two packages:
/packages/pkg1
,/packages/pkg2
If a commit like:
appears, pkg2 should not get a version bump, but currently,
semantic-release
does not support filtering commits by scope.Use cases
Monorepos with independent package versioning
feat(pkg1): Added logging
should bump pkg1's version, but pkg2's version should remain unchanged.Scoped commit filtering for better release control
feat(pkg1): ...
,fix(pkg2): ...
) to specifically indicate which package was modified.semantic-release
reads all commits, making it difficult to version packages separately in monorepos.Possible implementation
commit_scope_filter
option inpyproject.toml
semantic-release
only considers commits with the matching scope.semantic-release
behaves as it does today (reading all commits).commit_scope_filter
.semantic-release changelog
to support scope filteringAlternative solutions
semantic-release
per package.semantic-release
in isolated environments per package and limitinggit log
manually.This feature would greatly improve monorepo support in
semantic-release
by ensuring that only relevant commits impact versioning for each package.Best,
Asaf
The text was updated successfully, but these errors were encountered: