Search code examples
gitversionmonorepochangelog

How can I maintain an automatic changelog per module in a monorepo?


I'm working on a project which consists of multiple git repositories. There are multiple microservices, a frontend, some npm-packages and gateway containers, etc.

As I often run into the problem that for new features I have to change the code in multiple repositories i get lost in lots of pull requests.

To simplify this I am thinking about moving the repositories to a single monorepo. In fact, I already combined some of the npm packages in a single repository.

Until now i used standard-version for creating a changelog based on the git commits. I still want to have one changelog per module. Obviously this does not work out of the box with standard-version as it does check the commits per repository rather than per module directory.

Is it somehow possible to still create a changelog per module e.g. using only the commit messages where files in a directory where affected or using scopes in the commit messages? Any other ideas?

Normally every module will have it's own version, not all of them are JS/Node/npm-projects. It is also fine if I have to manage the publishing manually per module.


Solution

  • I don't know how you have configured your repository because you haven't provided any .versionrc file or package.json file examples, but there is a --path option for standard-version.

    From the help command:

    npx standard-version --help
    

    I got this:

    --path              Only populate commits made under this path                     [string]
    

    So you can either use that option in your package.json scripts as a parameter for your release command, or add it in your .versionrc.

    That should be easy if you have separate files for each package, if you have a global script you should just have separate release commands for each package with each path set for each command.