You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The idea would be that you could run lerna publish --skip-publish (a somewhat strange command if you read it like that) and it would do the git update, git tag, git push etc., but not npm publish the packages.
The motivation is that you could then setup Travis CI to do the releasing*. Travis already supports vanilla npm publish, but one could easily write a lerna publisher, that ran lerna publish --skip-git instead of npm publish.
Otherwise, I have to tell you, Lerna is great! I use it for publishing zipkin-js and the user experience is very smooth.
(*I hate releasing stuff from my Windows computer, because it does weird things to file permissions, and also I tend to mess up my local repo, so it's not a clean build like on Travis. And of course, I forget to run the tests too)
Running lerna publish --skip-publish and then lerna publish --skip-git doesn't make a lot of sense. You'd effectively be bumping versions twice, and the only solution otherwise would be for one to pick up where the last one left off which would be a weird behavior to introduce for the common-case.
It sounds like what you really want is a way to specify the next versions to be published by lerna inside CI without having to follow the prompts. sort of like:
@thejameskyle I think you may have misunderstood me a bit, this is what I want to achieve:
Run lerna [some-command] (maybe the command would be called prepare or prepare-publish?) locally/manually/from a developer machine, answer the prompts to choose a new version, and it will update package.json files, commit the changes, tag the commit and push it, like this:
But I don't want it to actually publish the packages to npm (npm publish). It should only do the "change package.json, make commit, make tag, push upstream" part. (And also detect which packages need to be published/version-bumped?)
Then, in Travis CI, there is a git receive hook, which registers that a new tag has been pushed. That, in turn, will trigger the deployment system: upload the packages to npm. And this is where Travis could be configured to lint the code, build the package, run the tests etc, before then running something like lerna publish --skip-git so that it actually uploads the package to npm.
(But doesn't make any changes to the code/do any git commits. CI isn't allowed to make commits to the git repository anyways, it only has read access)
You'd effectively be bumping versions twice
The version bump would only happen once, on the developer machine. When Travis receives the new code with the new git tag, the version would already be bumped (in the lerna-generated git commit)
How you choose to get these versions into CI is a bit outside of the scope of Lerna
Again, the version would be read from package.json which was recently updated by lerna, from the developer machine.
I guess that on the CI side, we could use a simple, stupid script like for each package: cd package/$NAME && npm publish; not much logic needed. On the developer side though, we would need to be able to use Lerna to generate that git commit/tag/push etc.
Yeah, I followed that originally. I'm fine with adding a flag to --skip-npm, but my concern is over running lerna publish --skip-npm and then running lerna publish --skip-git to pick up where it left off, because that's not what it is. It's more like --skip-npm and then --only-npm (which is how I would name it), but that would be very unusual behavior to introduce to the lerna publish process and I don't want to do it.
There's two options here:
Add something like lerna run that allows you to do something like lerna run npm publish (which would run npm publish in each package) - currently lerna run is for npm scripts so we would need something different like lerna exec
Add a way to specify versions for lerna publish like I suggested above. However, because your CI can't commit that doesn't fix the issue for you.
It's more like --skip-npm and then --only-npm (which is how I would name it)
This is what Maven does: it uses release:prepare (only the git stuff) and release:perform (only the upload artifacts stuff). Maybe we could have two commands lerna prepare-publish and lerna perform-publish? lerna publish would then be an alias for "lerna prepare-publish && lerna perform-publish"?
Using lerna exec publish on the CI server would of course solve the 2nd step of the problem. So what's really needed here is the --skip-npm flag. In CI, It's also possible to do lerna run publish and have an npm script called "publish" in every package, which does "npm publish" (it's hacky, and more indirection, but doesn't need any new features in Lerna).
currently lerna run is for npm scripts so we would need something different like lerna exec
It's a possibility to allow exceptions, like "lerna run publish" does "npm publish", "lerna run rebuild" runs npm rebuild. And if it doesn't exist in the list of exceptions ['publish', 'rebuild', ...] then it falls back to running the npm script. This would be a breaking change, but only in edge cases, like if somebody has created an npm script called "rebuild". I'm not sure if that's a breaking change you'd be willing to introduce in v2? (considering it's already in beta) It might not even be a good API decision.
--only-npm (which is how I would name it
I guess lerna publish --only-npm, which would be step 2 that runs on CI, in practice would be reduced to lerna run publish (or lerna exec publish if you wish) so we might not need a --only-npm flag in the first place. (Or is that what --skip-git already does?)
I'm fine with adding a flag to --skip-npm
Great! Running lerna publish --skip-npm would basically be step 1 like I described.
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Activity
hzoo commentedon May 12, 2016
Since
lerna publish --skip-publishdoes read weird, it might be better to split it into a separate command that just updates gitjamiebuilds commentedon May 12, 2016
Running
lerna publish --skip-publishand thenlerna publish --skip-gitdoesn't make a lot of sense. You'd effectively be bumping versions twice, and the only solution otherwise would be for one to pick up where the last one left off which would be a weird behavior to introduce for the common-case.It sounds like what you really want is a way to specify the next versions to be published by lerna inside CI without having to follow the prompts. sort of like:
How you choose to get these versions into CI is a bit outside of the scope of Lerna, but you could easily write a script to do it.
eirslett commentedon May 12, 2016
@thejameskyle I think you may have misunderstood me a bit, this is what I want to achieve:
lerna [some-command](maybe the command would be called prepare or prepare-publish?) locally/manually/from a developer machine, answer the prompts to choose a new version, and it will update package.json files, commit the changes, tag the commit and push it, like this:openzipkin/zipkin-js@b82aca8
But I don't want it to actually publish the packages to npm (
npm publish). It should only do the "change package.json, make commit, make tag, push upstream" part. (And also detect which packages need to be published/version-bumped?)lerna publish --skip-gitso that it actually uploads the package to npm.(But doesn't make any changes to the code/do any git commits. CI isn't allowed to make commits to the git repository anyways, it only has read access)
The version bump would only happen once, on the developer machine. When Travis receives the new code with the new git tag, the version would already be bumped (in the lerna-generated git commit)
Again, the version would be read from package.json which was recently updated by lerna, from the developer machine.
I guess that on the CI side, we could use a simple, stupid script like
for each package: cd package/$NAME && npm publish; not much logic needed. On the developer side though, we would need to be able to use Lerna to generate that git commit/tag/push etc.jamiebuilds commentedon May 12, 2016
Yeah, I followed that originally. I'm fine with adding a flag to
--skip-npm, but my concern is over runninglerna publish --skip-npmand then runninglerna publish --skip-gitto pick up where it left off, because that's not what it is. It's more like--skip-npmand then--only-npm(which is how I would name it), but that would be very unusual behavior to introduce to the lerna publish process and I don't want to do it.There's two options here:
lerna runthat allows you to do something likelerna run npm publish(which would runnpm publishin each package) - currentlylerna runis for npm scripts so we would need something different likelerna execlerna publishlike I suggested above. However, because your CI can't commit that doesn't fix the issue for you.eirslett commentedon May 12, 2016
This is what Maven does: it uses
release:prepare(only the git stuff) andrelease:perform(only the upload artifacts stuff). Maybe we could have two commands lerna prepare-publish and lerna perform-publish? lerna publish would then be an alias for "lerna prepare-publish && lerna perform-publish"?Using
lerna exec publishon the CI server would of course solve the 2nd step of the problem. So what's really needed here is the --skip-npm flag. In CI, It's also possible to dolerna run publishand have an npm script called "publish" in every package, which does "npm publish" (it's hacky, and more indirection, but doesn't need any new features in Lerna).It's a possibility to allow exceptions, like "lerna run publish" does "npm publish", "lerna run rebuild" runs npm rebuild. And if it doesn't exist in the list of exceptions
['publish', 'rebuild', ...]then it falls back to running the npm script. This would be a breaking change, but only in edge cases, like if somebody has created an npm script called "rebuild". I'm not sure if that's a breaking change you'd be willing to introduce in v2? (considering it's already in beta) It might not even be a good API decision.I guess
lerna publish --only-npm, which would be step 2 that runs on CI, in practice would be reduced tolerna run publish(orlerna exec publishif you wish) so we might not need a--only-npmflag in the first place. (Or is that what--skip-gitalready does?)Great! Running
lerna publish --skip-npmwould basically be step 1 like I described.gigabo commentedon May 21, 2016
I'd actually like to use
lerna publish --skip-npmoccasionally to get READMEs updated (until https://github.com/npm/newww/issues/389 is fixed). Let lerna get all of the versions updated and push the changes to github, but then manuallycdinto each package andnpm publishby hand. Unless there's a better workaround?Add --skip-npm flag
Add --skip-npm flag (#198)
gigabo commentedon Sep 6, 2016
Oh, @eirslett #198 landed two months ago, but I forgot to close this ticket. 😬
Please reopen (or open a new ticket) if that doesn't provide what you need!
lock commentedon Dec 28, 2018
This thread has been automatically locked because there has not been any recent activity after it was closed. Please open a new issue for related bugs.