mouuff / go-rocket-update

Easy to use and modular library to make self updating golang programs
Other
100 stars 10 forks source link

Proposal: use semantic versioning comparison for "GetLatestVersion()" #15

Open axllent opened 3 years ago

axllent commented 3 years ago

I note that the provider GetLatestVersion() doesn't return the latest version necessarily, but rather the latest release (ie: first result). I guess that in most cases the latest release is the latest version, however this assumption isn't always correct. For example an app may have two separate major version releases 1.x.x & 2.x.x, however if the 1.x.x is released after the 2.x.x then it will show as the GetLatestVersion().

A better way (I think) to address this, as well support the planned feature of release channels (across all providers), is to do semantic version comparisons instead for all versions (returned from API).

Regarding semantic version comparisons, one issue I ran into was that depending what library / method you use. Some developers tag it v1.2.3, others just 1.2.3, and some apps tag it as v1.2.3 and then use 1.2.3 in their app version itself. I found it safest just to ignore (strip) the leading optional v in the semantic version comparison in all cases, that way I was always able to compare versions correctly.