geut / lerna-travis-demo

Just a simple monorepo with a publish-from-travis setup and chan support.
33 stars 9 forks source link

npm login issue #37

Closed wahengchang closed 5 years ago

wahengchang commented 5 years ago

I think everything is setup well , but still seeing this error. Do you have a crew about what is going wrong? I spent few days seting up this CI/CD

$ lerna publish from-git --yes --npm-client yarn --npm-tag beta
WARN deprecated --npm-tag has been renamed --dist-tag
lerna notice cli v3.10.5
lerna info ci enabled
lerna WARN Yarn's registry proxy is broken, replacing with public npm registry
lerna WARN If you don't have an npm token, you should exit and run `npm login`
lerna ERR! EUNCOMMIT Working tree has uncommitted changes, please commit or remove changes before continuing.

NPM_TOKEN is init on the config

image

travis-ci

dpaez commented 5 years ago

Hi @wahengchang 👋 It seems like you are almost done. I've found the same issue and in my case was related to how Lerna handles their lifecycle scripts. I was thinking it was something similar to what npm or yarn does (e.g.: preversion, version, postversion, etc). But it's different.

To solve that I've added one extra step, the lerna:postversion piece.

The problem basically is that you have uncommitted files on travis. So, you can look for that. Something is being modified inside of your ci/cd pipeline.

In this case your postversion script is the one I recommend to automatically update your changelog using chan. According to your package devdeps, chan is missing. You should install it or remove the whole postversion part.

If you want to have a partially automated changelog 🆒 as a part of your project, you should install chan as a dev dep, then run npx chan init, this only needs to run once to generate a valid CHANGELOG.md file and push the new file.

Hope this helps. 👍

wahengchang commented 5 years ago

@dpaez , i spent another morning to try out, and did all you mentioned.

the script fail in lerna:publish, as the reason EUNCOMMIT Working tree has uncommitted changes.

I am thinking if it is a problem caused by different lerna version ? is your repo still working ? would you mind providing the travis-ci web for reference ?

I am building a CICD for my team, to build and publish a new version on npm for each commit on master branch. Working with lerna and travis-ci is harder than I imagine.

dpaez commented 5 years ago

Hi @wahengchang. This is the travis-ci web output/config for one of our last releases. Check it out.

I don't think different lerna versions are the problem since we are on the same major number.

I think the Travis script part should only run a few commands, like lerna:publish. This one will trigger others. Also, how are you starting the procedure? I mean, according to the info provided on this test repo, one first run yarn run lerna:version this creates a tagged commit and push it to the repo. Travis then detects this tagged commit (thanks to the tags: true config) and starts the 2nd part, the publish one.

wahengchang commented 5 years ago

I am digging into A. Fully "automatic" part.

my work flow:

I did all the same as the repo you provided (copy paste package.json and .travis.yml), is it the right way?

dpaez commented 5 years ago

Ok, I thought you were trying to use the other workflow ("half & half"). Take a look on this package.json (branch: fully-auto).

You will see that the version script does not call the lerna:postversion hook. I think that will help you. 👍

dpaez commented 5 years ago

Hi @wahengchang, have you made some progress with this?

dpaez commented 5 years ago

I'm closing this since there was no update. Feel free to re-open if the issue persists.

wahengchang commented 5 years ago

close it plz, i dont have a crew what is going wrong. i did not work on the CI/CD for few week, i will be back in the future.

thx dp :)