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

v-prefix in package.json version causes false negative during version comparison #139

Closed
scraly opened this issue Sep 12, 2023 · 2 comments · Fixed by #147
Closed

v-prefix in package.json version causes false negative during version comparison #139

scraly opened this issue Sep 12, 2023 · 2 comments · Fixed by #147
Labels
bug Something isn't working

Comments

@scraly
Copy link

scraly commented Sep 12, 2023

Hi,

I've got an issue.
Even if a npm package altready exists with the current version, the gh action wants to publish it again:

npm ERR! 403 403 Forbidden - PUT https://registry.npmjs.org/@xxx%2fxxx - You cannot publish over the previously published versions: 0.34.0.

My GH action:

      - if: ${{ matrix.language == 'nodejs' && env.PUBLISH_NPM == 'true' }}
        uses: JS-DevTools/[email protected]
        with:
          access: "public"
          token: ${{ env.NPM_TOKEN }}
          package: ${{github.workspace}}/sdk/nodejs/bin/package.json
          provenance: true

I've tried with strategy: upgrade without success.

Thanks

@scraly
Copy link
Author

scraly commented Sep 12, 2023

After several tried, the strategy upgrade resolved it... crossed fingers for the next time :)

@scraly scraly closed this as completed Sep 12, 2023
@mcous
Copy link
Member

mcous commented Sep 12, 2023

Hi @scraly, that doesn't sound good. Is this the repository? https://github.com/ovh/pulumi-ovh

If so, I believe the cause is that in your package.json, the version field is v0.34.0. I've always seen the version field without the v, because that's what the npm version command writes.

  {
      "name": "@ovh-devrelteam/pulumi-ovh",
-     "version": "v0.34.0",
+     "version": "0.34.0",

I didn't truthfully know that npm would accept that! But, since node-semver can parse it, npm seems happy. The bug in npm-publish is that it only checks strings in the default strategy. It calls npm info @ovh-devrelteam/pulumi-ovh and receives 0.34.0 from npm. Since 0.34.0 !== v0.34.0 (from npm and the package.json, respectively), it tries to publish.

The reason strategy: upgrade works is because in the upgrade strategy, we pass both versions into node-semver to compare them

@mcous mcous reopened this Sep 12, 2023
@mcous mcous added the bug Something isn't working label Sep 12, 2023
@mcous mcous changed the title Try to publish npm package even if already exists in the registry v-prefix in package.json version causes false negative during version comparison Sep 12, 2023
mcous added a commit that referenced this issue Sep 13, 2023
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

Successfully merging a pull request may close this issue.

2 participants