mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-21 22:30:46 +08:00
26 lines
622 B
Go
26 lines
622 B
Go
package update
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/blang/semver"
|
|
"github.com/pkg/errors"
|
|
"github.com/rhysd/go-github-selfupdate/selfupdate"
|
|
)
|
|
|
|
func CheckUpgrade(currentVersion string) (bool, *selfupdate.Release, error) {
|
|
latest, found, err := selfupdate.DetectLatest("Li4n0/revsuit")
|
|
if err != nil {
|
|
return false, nil, errors.Wrap(err, "error when detecting version")
|
|
}
|
|
|
|
v, err := semver.Parse(strings.TrimPrefix(currentVersion, "v"))
|
|
if err != nil {
|
|
return false, nil, errors.Wrap(err, "error when parse version")
|
|
}
|
|
if !found || latest.Version.LTE(v) {
|
|
return false, nil, nil
|
|
}
|
|
return true, latest, nil
|
|
}
|