Skip to content

Add --skip-publish option, like --skip-git #127

Closed

Description

@eirslett

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.

So .travis.yml would look like this:

# build config etc. first

# deploy config
deploy:
  provider: lerna
  email: [email protected]
  api_key:
    secure: XXX
  on:
    tags: true
    repo: some/repo

It would also require an update to https://github.com/travis-ci/dpl, which is Travis' deployment tool, so that it could support lerna.

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)

Activity

  1. hzoo commented on May 12, 2016

    @hzoo
    Contributor

    Since lerna publish --skip-publish does read weird, it might be better to split it into a separate command that just updates git

  2. jamiebuilds commented on May 12, 2016

    @jamiebuilds
    Contributor

    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:

    # non-independent:
    $ lerna publish --specify-version minor
    # independent:
    $ lerna publish --specify-version package-1:major package-2:minor package-3:1.2.3

    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.

  3. eirslett commented on May 12, 2016

    @eirslett
    Author

    @thejameskyle I think you may have misunderstood me a bit, this is what I want to achieve:

    1. 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:

    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?)

    1. 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.

  4. jamiebuilds commented on May 12, 2016

    @jamiebuilds
    Contributor

    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.
  5. eirslett commented on May 12, 2016

    @eirslett
    Author

    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.

  6. gigabo commented on May 21, 2016

    @gigabo
    Contributor

    I'd actually like to use lerna publish --skip-npm occasionally 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 manually cd into each package and npm publish by hand. Unless there's a better workaround?

  7. added a commit that references this issue on Jun 9, 2016
  8. added a commit that references this issue on Jun 9, 2016
  9. gigabo commented on Sep 6, 2016

    @gigabo
    Contributor

    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!

  10. lock commented on Dec 28, 2018

    @lock

    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.

  11. locked as resolved and limited conversation to collaborators on Dec 28, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions