Skip to content

Custom tag template when independent versioning #3902

@kpau

Description

@kpau

Description

We have a mono-repo with individual versioning.
We use lerna version --conventional-commits --git-tag-version false to bump package versions and generate changelogs.
After that we use lerna publish from-package to release the packages.

By default, lerna generates tags in the format @scope/package-name@X.Y.Z.
We disable the auto-generated lerna tags and as part of our release process, we create git tags in the format package-name/vX.Y.Z (without the @scope).

With custom tag names, lerna changed, lerna diff and lerna version successfully detects which packages are changed since the last release. Unfortunately, when generating the changelogs, it ignores the custom tags and searches for tags with the default name.

I would like to have an option to change the tag format that lerna uses.

Motivation

There are two reasons we prefer the different format:

  1. The @scope is the same for all our packages, so no need to add it. It only adds noise.
  2. Some GUI tools (e.g. GitLens) visually group the list of tags into folders. They use / as a separator. With the default format it will create one folder @scope with all tags in it. With our custom format it will create individual folders for each package, with the tags just for that package.

Suggested Implementation

While investigating why lerna version is not able to generate the correct change logs, I saw that it uses conventional-recommended-bump which uses git-semver-tags. The latter uses the @scope/package-name@X.Y.Z format. Lerna itself does not care about the names of the tags, as long there is tag for every release.

For independent versioning --tag-version-prefix is ignored. We can make use of it and add a placeholders for package name and scope, for example:

  • %s for the "@scope" and %p for "package-name".
  • --tag-version-prefix '%s/%p@' for the default tag names.
  • --tag-version-prefix '%p/v' for our custom naming.

Lerna will use the prefix when generating tags.
The prefix can be provided as tagPrefix to conventional-recommended-bump and git-semver-tags.

Alternate Implementations

For now, we'll stick with the default lerna tag names, but really hope to consider adding such a feature.
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions