JS-DevTools / npm-publish

GitHub Action to publish to NPM
https://jstools.dev/npm-publish
MIT License
613 stars 74 forks source link

Support for snapshot versions #202

Closed rrigoni closed 2 months ago

rrigoni commented 3 months ago

Why this library throws the following error if I use any release different than {major}.{minor}.{patch}? Anything like {major}.{minor}.{patch}-snapshot or even {major}.{minor}.{patch}.something throws the following error:

Run JS-DevTools/npm-publish@v2
  with:
    token: ***
    package: ./package.json
Error: InvalidPackageVersionError: Package version must be a string, got "undefined"

Happening with node 18 on github actions.

mcous commented 3 months ago

Hi @rrigoni, it looks like you're not using the latest version of this action, which includes at least one important fix related to the version string: #161. Is this occurring in a public repository? If so, I'd be happy to take a look if you could provide me with a link.

This error occurs if your package.json#version field is not parsable by node-semver. semver.valid allows "prerelease" versions, so I suspect something is likely wrong with your package.json file

const semver = require("semver")

console.log('Valid?', semver.valid('1.2.3-snapshot'))
// Logs `Valid? 1.2.3-snapshot`

I recommend that you

mcous commented 3 months ago

@rrigoni are you still having an issue here? I am unable to reproduce any issues with snapshot versions; my tests are showing successful publishing of prerelease packages

mcous commented 2 months ago

Closing due to lack of reproduction or activity