Can Lerna bump prerelease version according to the Conventional Commits specification?
Asked Answered
M

2

5

It doesn't seem that Lerna 3.20.2 is able to bump prerelease versions (e.g. 1.0.0-alpha.0) according to the Conventional Commits specification.

I made a Minimal Reproducible Example if you want to try this out.

Say we have two Lerna-managed repositories, both with three sub-packages. One repo has "production" packages the other has "prerelease" ones:

dev (or dev-prerelease)
  |-- packages
  |   |-- major
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |   |-- minor
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |   |-- patch
  |   |   |-- package.json (1.0.0 or 1.0.0-alpha.0)
  |-- package.json
  |-- lerna.json

I then make the following commits in both repositories: (commits follow the Conventional Commits specification)

  • A breaking change in the major package
  • A new feature in the minor package
  • A bug fix in the patch package

And run this command in both repositories:

npx lerna publish --conventional-commits --yes 2>/dev/null

Observations

The "production" repo sees its packages updated according to the Conventional Commits spec:

Changes:
 - major: 1.0.0 => 2.0.0 (private)
 - minor: 1.0.0 => 1.1.0 (private)
 - patch: 1.0.0 => 1.0.1 (private)

However in the prerelease repo, all packages are simply "patched":

Changes:
 - major: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)
 - minor: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)
 - patch: 1.0.0-alpha.0 => 1.0.0-alpha.1 (private)

The thread in this GitHub issue seems to suggest that this is a bug (but I'm not sure).

Question I'd like the packages in my "prerelease" repo to be updated in the same way as in the "production" repo whilst retaining their prerelease suffix. What am I doing wrong here?


You can also follow up this GitHub issue that I raised

Miquelon answered 10/4, 2020 at 16:30 Comment(0)
M
8

I used the following command:

lerna publish --conventional-commits --conventional-prerelease

The version bumps for these flags are explained in the below image:

table-with-conventional-prerelease

Mcreynolds answered 8/12, 2020 at 3:5 Comment(3)
Running lerna publish prerelease bumped my version from 0.3.3-alpha.0 -> 0.3.3-alpha.1. Adding the --conventional-commits flag made no difference to the behaviour.Katelin
@JamieBirch What's your commits before this command? Is there any commit with keyword like BREAKING CHANGE in footer (which makes a major version bump)?Mcreynolds
My previous release was 0.3.3-alpha.0. From that time onwards, I made 18 commits, and only one of them included a keyword (which was "feat:"). So I think it doesn't examine the commit messages at all; it just decides how to bump the version entirely based on the term that you write in the command, e.g. prerelease in the case of lerna publish prerelease.Katelin
N
2

Had the same issue:

you have to go through the lerna versioning commands

  • lerna version major

  • lerna version premajor

  • lerna version prerelease

now you will see that all the changes made it in your lerna.json (this is where the actual version is kept, and the version command is the only one changing the MAJOR, MINOR and PATCH numbers)

Nonrepresentational answered 5/5, 2020 at 13:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.