简体   繁体   中英

How to manage canary version bump in monorepo with lerna from different branches

Let's assume we've got typescript project with monorepo structure and lerna as a tool for versioning and publishing packages. We have to implement two different changes but both are affecting one package. At the begginig we have package foo@1.0.0 . One developer had implemented feat on his branch (dev-foo) and want to test it. Using:

lerna version --include-merged-tags --conventional-prerelease

lerna will bump version of package foo to foo@1.1.0-alpha.0 , commit prerelease and push it to origin.

At the same time another dev did the second change on his own branch (dev-bar) and wants to prerelease his changes. Using command above lerna would attempt to bump version on package foo@1.0.0 also to foo@1.1.0-alpha.0 but the command will fail because tag foo@1.1.0-alpha.0 already exists. It happens after git fetch also.

How to prevent such behaviour? Suitable solution would be to bump such versions to foo@1.1.0-alpha.0 and foo@1.1.0-beta.0 . How to achieve that?

How to prevent lerna from bumping package version to one already existed but not merged? Like canary version bumped on dev-foo branch? In another words - how to support independent development and prerelase tagging of the same workspace?

For this you can use lerna publish --canary --preid beta to get the tag as mentioned in the lerna doc it self.

--preid Unlike the lerna version option of the same name, this option only applies to --canary version calculation.

lerna publish --canary
# uses the next semantic prerelease version, e.g.
# 1.0.0 => 1.0.1-alpha.0

lerna publish --canary --preid next
# uses the next semantic prerelease version with a specific prerelease identifier, e.g.
# 1.0.0 => 1.0.1-next.0

When run with this flag, lerna publish --canary will increment premajor, preminor, prepatch, or prerelease semver bumps using the specified prerelease identifier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM