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

Master build will attempt to publish the previous version. #988

Closed
liorheber opened this issue Feb 24, 2020 · 18 comments
Closed

Master build will attempt to publish the previous version. #988

liorheber opened this issue Feb 24, 2020 · 18 comments
Labels
bug Something isn't working

Comments

@liorheber
Copy link

liorheber commented Feb 24, 2020

Describe the bug

npm version never increments between master builds.
After a successful publish to npm, if I merge a new PR that doesn't manually bump the version in package.json the shipit command will attempt to publish the previous version again which fails with -

npm ERR! 403 403 Forbidden - PUT https://registry.yarnpkg.com/@kenshooui%2freact-tree - You cannot publish over the previously published versions: 0.0.16.
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy.

To Reproduce

  1. Got an npm package that is published independently inside a monorepo.
    package.json has a version set to 1.1 for example which is already published.

  2. I issue a new PR and when I merge it shipit attempts to publish 1.1 again.

  3. (*) When a new tag is generated, using the TravisCI documentation you provided, it will release a canary version of the package.

Expected behavior

I'd expect shipit to publish 1.1.1 and/or update the package.json version.

Environment information:

Environment Information:

"auto" version: v9.13.0
"git"  version: v2.22.0
"node" version: v12.14.1

Project Information:

✔ Repository:      kenshoo/react-tree (​https://github.com/kenshoo/react-tree​)
✔ Author Name:     Lior
✔ Author Email:    lior.heber@kenshoo.com
✔ Current Version: v0.0.15
✔ Latest Release:  v0.0.16 (​https://github.com/kenshoo/react-tree/releases/tag/v0.0.16​)

✔ Labels configured on GitHub project 

GitHub Token Information:

✔ Token:            [Token starting with c5f0]
✔ Repo Permission:  admin
✔ User:             uikenshoo
✔ API:              https://api.github.com (​https://api.github.com​)
✔ Enabled Scopes:   repo, read:org, user:email, repo_deployment, repo:status, write:repo_hook, write:packages, read:packages
✔ Rate Limit:       4974/5000

Additional context

The project is empty and public so auto, travis.yml and the travis build are all visible.
I'm sure it's something wrong that I'm doing but I'd appreciate any pointer.

Please note that while the project is a monorepo, I'm using auto on a single package.

@liorheber liorheber added the bug Something isn't working label Feb 24, 2020
@hipstersmoothie
Copy link
Collaborator

Please note that while the project is a monorepo, I'm using auto on a single package.

Without reading into this too much I think this is the problem. If you're using lerna it will try to publish with lerna instaed of npm. Looking into this more now though

@hipstersmoothie
Copy link
Collaborator

Can you link me to that build?

@liorheber
Copy link
Author

I'm not using Lerna but yarn workspaces and preconstruct.
This is the build -
https://travis-ci.org/kenshoo/react-tree/builds/654544555?utm_source=github_status&utm_medium=notification

@hipstersmoothie
Copy link
Collaborator

I'm getting a PR together that should set this up correctly. Currently with the npm plugin lerna is a required peer dep for publishing. I'll set this up for you too.

In the future this may not be the case with #917. But that could be a ways off because I want to keep auto stable for a while.

@hipstersmoothie
Copy link
Collaborator

kenshoo/react-tree#25

@liorheber
Copy link
Author

Thanks, I appreciate your above and beyond assistance!
I'll let you know if that helped.

@hipstersmoothie
Copy link
Collaborator

Damn that didn't work. Seems to be a git issue now though. We had docs to checkout master but i though that wasn't needed anymore.

@hipstersmoothie
Copy link
Collaborator

Seems like you might need to checkout a branch before running shipit on master

f64d39e#diff-fae94f6c969367129f745870a97c116f

@hipstersmoothie
Copy link
Collaborator

lerna/lerna#2314

@hipstersmoothie
Copy link
Collaborator

lerna/lerna#839

@liorheber
Copy link
Author

Interesting, I'll do some reading but won't that break the canary release?

@hipstersmoothie
Copy link
Collaborator

I would only do that on master. All other types of releases do not require the ability to commit.

@hipstersmoothie
Copy link
Collaborator

deploy:
  - provider: script
    script: if [ "$NPM_TOKEN" != "false" ];then 
        if [ "$TRAVIS_BRANCH" == "master" ];then 
          git checkout master;
        fi;

        yarn release;
      fi;
    skip-cleanup: true
    on:
      all_branches: true

@hipstersmoothie
Copy link
Collaborator

hipstersmoothie commented Feb 24, 2020

I'm contemplating whether the npm+lerna plugin should just do this itself

EDIT: I dont think I want to. since do this automatically might break some other behavior and this is very dependent on build platform. I'm just gonna add some docs around it

@liorheber
Copy link
Author

Sorry if this is getting a bit out of scope but it looks like the change also broke the PR build.
For some reason it's not using the NPM_TOKEN now.
https://travis-ci.org/kenshoo/react-tree/builds/654591331#L303

Any chance it's not generating npmrc properly?

@hipstersmoothie
Copy link
Collaborator

I think I wrote the yml incorrectly sh: 1: [: checkout-master-on-release: unexpected operator

@hipstersmoothie
Copy link
Collaborator

We can update this PR with your findings: https://github.com/intuit/auto/pull/990/files

@liorheber
Copy link
Author

Looks like the final change got it to work
https://github.com/kenshoo/react-tree/blob/master/.travis.yml is the final version.
Like I mentioned, I had to add some more logic to the branch check.

Thanks so much for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants