The Wayback Machine - https://web.archive.org/web/20201104074737/https://github.com/lerna/lerna/issues/2022
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish command needs more docs around Travis-CI configuration #2022

Open
jedmao opened this issue Apr 5, 2019 · 1 comment
Open

Publish command needs more docs around Travis-CI configuration #2022

jedmao opened this issue Apr 5, 2019 · 1 comment

Comments

@jedmao
Copy link

@jedmao jedmao commented Apr 5, 2019

It took me way too long and far too many Travis-CI builds to figure out the right configuration for Travis-CI to run lerna publish with everything it needed. I'm still not 100% sure if everything I'm doing is necessary, but perhaps it will help others to share my findings. Even better if there was some documentation around this.

My goals

  1. Automatically npm publish each relevant package in the monorepo when a PR is merged into master.
  2. Automatically cut a release by pushing a publish commit via git push.
  3. Only do the above on Travis-CI builds on the master branch.

Solution

Add .npmrc to .gitignore.

.travis.yml

after_success:
  - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
  - git remote add pub https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git
  - git fetch pub master # needed?
  - git checkout master # got an error w/o this one

deploy:
  - provider: script
    script: npx lerna publish --git-remote pub
    skip_cleanup: true
    keep_history: true
    on:
      branch: master

Shouldn't the GH_TOKEN and TRAVIS_REPO_SLUG automatically be used in the first place? I'm hoping there's an easier way to compress these steps.

lerna.json

{
  "packages": ["packages/*"],
  "version": "independent",
  "command": {
    "publish": {
      "conventionalCommits": true,
      "yes": true // Needed in the CI env? I don't want to wait for another build to find out.
    }
  }
}

Conclusion

Be great if there was some documentation around all these steps together.

@evocateur
Copy link
Member

@evocateur evocateur commented May 10, 2019

  1. I don't believe the git fetch pub master is needed, but you should auto-fetch the pub remote (pass -f to the git remote add line)
  2. git checkout master is necessary to turn the default headless clone into a "named" ref (master).
  3. You should pass --yes to the npx script, don't configure it in lerna.json (otherwise anyone attempting to run lerna publish will always skip prompts)
  4. You should probably configure command.publish.allowBranch = ["master"] in lerna.json, just so folks don't get any ideas.
  5. Documentation would be great. PRs welcome.
whatwewant added a commit to zcorky/zodash that referenced this issue Jun 20, 2019
…search

- references
 - keyword: lerna independent publish travis ci (lerna/lerna#2022)
 - repo: https://github.com/jedmao/queso
whatwewant added a commit to zcorky/zodash that referenced this issue Jun 20, 2019
…search

- references
  - keyword: lerna independent publish travis ci (lerna/lerna#2022)
  - repo: https://github.com/jedmao/queso
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants
You can’t perform that action at this time.