lerna version: createRelease is false when `--no-push` is passed in

Created on 21 Oct 2019  路  3Comments  路  Source: lerna/lerna

Expected Behavior

A release should be able to be created even if lerna version doesn't handle the push.

Current Behavior

lerna version will not create a release if push is set to false:
https://github.com/lerna/lerna/blob/master/commands/version/index.js#L78

Possible Solution

Remove the dependency on pushToRemote from createRelease or add an additional flag, something like --create-release-only that will create a release without pushing.

Alternatively, we can create the Github release on our own, but since the logic is already built into Lerna it would be helpful to be able to use it.

Context

I am working with a monorepo that has a few packages with one that requires a package-lock. The setup looks a bit like this:

package.json
lerna.json
packages/
    packageOne/
        package.json
    packageTwo/
        package.json
        package-lock.json

PackageTwo has a dependency on packageOne, but also requires a package-lock for other dependencies. Currently we are manually updating the package-lock in package-two in between lerna version and lerna publish as inspired by https://github.com/lerna/lerna/issues/1415#issuecomment-455790478. This is what our CI script looks like:

# Update package versions
lerna version --conventional-commits --create-release github -m '[skip ci] chore(release): publish' --yes --no-push

# Publish new package versions
lerna publish from-package --yes

# Update docs package lock with new package versions
cd packages/packageTwo && npm install packageOne@latest --package-lock-only --ignore-scripts --no-audit && git add ./package-lock.json

# Add package lock to existing versions commit
git commit --amend --no-edit

# Push version and the github releases. Remove --follow-tags to stop github releases
git push origin master --follow-tags

However, since a Github release is never actually created, --follow-tags doesn't push up any tags. Additionally, since we are publishing using from-package we also don't need to push the release to the remote until after the package-lock has been updated. Ideally, the Github release is created and the tags can be pushed manually.

This later results in a problem with lerna changed. Lerna uses the git tags as a diff for which packages needs to be updated. Since the tags/releases are never created or pushed to the remote, lerna changed can't properly determine which packages need to be updated.

Alternatively, if there's a better approach to handling a package-lock, we'd also be happy to try that.

Most helpful comment

v3.18.2 fixes this

All 3 comments

A Github Release literally requires the tags to be present, though?

Seems like we could just fix the "update package-lock during versioning" bug and you wouldn't need all this ornate scripting.

Thanks @evocateur! I definitely agree that https://github.com/lerna/lerna/pull/2160 is the proper solution to all of this. However, since it seems like #2160 has stalled I was hoping to get a workaround, maybe the best answer is to manually handle tagging and creating a release until the update package-lock during versioning bug is resolved?

v3.18.2 fixes this

Was this page helpful?
0 / 5 - 0 ratings