Standard-version: Usage in monorepo nx workspace

Created on 26 Aug 2019  路  7Comments  路  Source: conventional-changelog/standard-version

Hi,
I am using nx workspace to handle multiple angular projects as well as shared libraries.
Let' s assume a folder structure like this:

|_package.json
|_CHANGELOG.md
|_projectA
  |_package.json
  |__CHANGELOG.md
|_projectB
  |_package.json
  |_CHANGELOG.md

I am trying to figure out a way to use conventional-changelog in my release process. I want to have seperated changelogs for each project and one root changelog. By using conventional commits I would like to somehow define the scope of the commit (e.g. that this feat() only affects projectA and thus, is only mentioned in this specific changelog.

Is this possible or is this a wrong approach in a monorepo?

Help appreciated.

help wanted question

Most helpful comment

@sidyes I think I've found a solution. It's not ideal, but it'll do for now.

You put an .versionrc file in each sub folder with the "path": "." config. Then you run standard-version from each sub folder you want to update the changelog for.

Example
https://github.com/snebjorn/akita/blob/refactor/nx-workspace/libs/akita-ng-entity-service/

All 7 comments

@sidyes did you make any progress on this?
I'm trying to do the exact same

@sidyes did you make any progress on this?
I'm trying to do the exact same

Unfortunatelly, I did not and currently I am just living with the all-in-one changelog.
I would still love to have a solution for this...

@sidyes I think I've found a solution. It's not ideal, but it'll do for now.

You put an .versionrc file in each sub folder with the "path": "." config. Then you run standard-version from each sub folder you want to update the changelog for.

Example
https://github.com/snebjorn/akita/blob/refactor/nx-workspace/libs/akita-ng-entity-service/

@sidyes I think I've found a solution. It's not ideal, but it'll do for now.

You put an .versionrc file in each sub folder with the "path": "." config. Then you run standard-version from each sub folder you want to update the changelog for.

Example
https://github.com/snebjorn/akita/blob/refactor/nx-workspace/libs/akita-ng-entity-service/

Ok, so it automatically recognizes the changes only for this specific folder and creates a CHANGELOG for this?
Other commits from other scopes are automatically ignored?

I believe so. My initial test worked. But haven't used it in the wild yet.
But wait. There's more! 馃巿 馃帀

I managed to improve upon it quite a bit. This combo makes it work from the repo root and without standard-version globally installed!

files in project folder:
.yarnrc
.versionrc

npm script in root:
"release:akita-entity-service": "yarn --cwd libs/akita-entity-service run standard-version"

Working for me, thank you. 馃憤

In case someone else runs into the same problem as me:

Since each repo in my mono repo has a different version and standard-version assumes you only want tags for one version, it often ended up mixing up the tags of the different repos. Causing the compareUrl to compare 3.0.9 with 10.12.5 and obviously not finding anything.

I solved this by using -t/--tag-prefix.
With this, you can make sure, that each repo in your mono repo has their own version tags.
This option is documented when running standard-version --help but not documented in the docs.

Hope this helps someone else as well.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

vidavidorra picture vidavidorra  路  5Comments

kimnh-0823 picture kimnh-0823  路  4Comments

jefftienchow picture jefftienchow  路  5Comments

eemeli picture eemeli  路  4Comments

pdcmoreira picture pdcmoreira  路  4Comments