|
3 | 3 | This tutorial assumes the monorepo layout is designed with multiple components that can be released independently of each |
4 | 4 | other, it also assumes that conventional commits with scopes are in use. Some suggested layouts: |
5 | 5 |
|
6 | | -``` |
| 6 | +```shell-session |
7 | 7 | . |
8 | 8 | ├── library-b |
9 | 9 | │ └── .cz.toml |
10 | 10 | └── library-z |
11 | 11 | └── .cz.toml |
12 | 12 | ``` |
13 | 13 |
|
14 | | -``` |
| 14 | +```shell-session |
15 | 15 | src |
16 | 16 | ├── library-b |
17 | 17 | │ └── .cz.toml |
18 | 18 | └── library-z |
19 | 19 | └── .cz.toml |
20 | 20 | ``` |
21 | 21 |
|
22 | | -Each component will have its own changelog, commits will need to use scopes so only relevant commits are included in the |
23 | | -appropriate change log for a given component. Example config and commit for `library-b` |
| 22 | +Sample `.cz.toml` for each component: |
24 | 23 |
|
25 | 24 | ```toml |
| 25 | +# library-b/.cz.toml |
26 | 26 | [tool.commitizen] |
27 | 27 | name = "cz_customize" |
28 | 28 | version = "0.0.0" |
29 | 29 | tag_format = "${version}-library-b" # the component name can be a prefix or suffix with or without a separator |
30 | 30 | update_changelog_on_bump = true |
| 31 | +``` |
| 32 | + |
| 33 | +```toml |
| 34 | +# library-z/.cz.toml |
| 35 | +[tool.commitizen] |
| 36 | +name = "cz_customize" |
| 37 | +version = "0.0.0" |
| 38 | +tag_format = "${version}-library-z" |
| 39 | +update_changelog_on_bump = true |
| 40 | +``` |
| 41 | + |
| 42 | +And finally, to bump each of these: |
| 43 | + |
| 44 | +```sh |
| 45 | +cz --config library-b/.cz.toml bump --yes |
| 46 | +cz --config library-z/.cz.toml bump --yes |
| 47 | +``` |
31 | 48 |
|
| 49 | + |
| 50 | +## Changelog per component |
| 51 | + |
| 52 | +In order to filter the correct commits for each component, you'll have to come up with a strategy. |
| 53 | + |
| 54 | +For example: |
| 55 | + |
| 56 | +- Trigger the pipeline based on the changed path, which can have some downsides, as you'll rely on the developer not including files from other files |
| 57 | + - [github actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#onpushpull_requestpull_request_targetpathspaths-ignore) uses `path` |
| 58 | + - [Jenkins](https://www.jenkins.io/doc/book/pipeline/syntax/#built-in-conditions) uses `changeset` |
| 59 | + - [Gitlab](https://docs.gitlab.com/ee/ci/yaml/#ruleschanges) uses `rules:changes` |
| 60 | +- Filter certain pattern of the commit message (recommended) |
| 61 | + |
| 62 | + |
| 63 | +### Example with scope in conventional commits |
| 64 | + |
| 65 | +For this example, to include the message in the changelog, we will require commits to use a specific scope. |
| 66 | +This way, only relevant commits will be included in the appropriate change log for a given component, and any other commit will be ignored. |
| 67 | + |
| 68 | +Example config and commit for `library-b`: |
| 69 | + |
| 70 | +```toml |
32 | 71 | [tool.commitizen.customize] |
33 | 72 | changelog_pattern = "^(feat|fix)\\(library-b\\)(!)?:" #the pattern on types can be a wild card or any types you wish to include |
34 | 73 | ``` |
35 | 74 |
|
36 | | -example commit message for the above |
| 75 | +A commit message looking like this, would be included: |
37 | 76 |
|
38 | | -`fix:(library-b) Some awesome message` |
39 | | - |
40 | | -If the above is followed and the `cz bump --changelog` is run in the directory containing the component the changelog |
41 | | -should be generated in the same directory with only commits scoped to the component. |
| 77 | +``` |
| 78 | +fix:(library-b) Some awesome message |
| 79 | +``` |
0 commit comments