electron-builder
electron-builder copied to clipboard
electron-updater: `allowPrerelease = true` doesn't work when tag is not a valid input to `semver.prerelease()`
Problem
The algorithm that determines whether there is a new prerelease version available for download uses assumes that the tag name is the version and uses it as an input to semver.prerelease()
to determine the prerelease channel (see here). This only works when the tag is in the format {num}.{num}.{num}-{prerelease}.{number}
or with a v
prefix. It doesn't work for any other prefix than v
. For example, it is a very common case for monorepos to prefix their tags with the name of their apps/packages (as the changesets
package does for example)
> semver.prerelease('1.0.0-rc.0')
[ 'rc', 0 ]
> semver.prerelease('v1.0.0-rc.0')
[ 'rc', 0 ]
> semver.prerelease('[email protected]')
null
Solution
When allowPrerelease = true
, instead of using hrefTag
as input to the semver.prerelease()
function to determine the channel, it should get the version
from the latest*.yml
file of the release that has the tag hrefTag
, just like it happens when allowPrerelease = false