Don't update prerelease

This commit is contained in:
2022-02-18 09:22:13 +01:00
parent ce46b848dd
commit 2f1840d6fb

View File

@@ -43,18 +43,26 @@ func CheckLatestVersion() (string, []Asset, error) {
// Get tag_name from the json response // Get tag_name from the json response
var release = struct { var release = struct {
TagName string `json:"tag_name"` TagName string `json:"tag_name"`
Assets []Asset `json:"assets"` Assets []Asset `json:"assets"`
PreRelease bool `json:"prerelease"`
}{} }{}
err = json.NewDecoder(resp.Body).Decode(&release) err = json.NewDecoder(resp.Body).Decode(&release)
if err != nil { if err != nil {
return "", nil, err return "", nil, err
} }
// if it's a prerelease, don't update
if release.PreRelease {
return "", nil, errors.New("Prerelease detected, not updating")
}
// no tag, don't update
if release.TagName == "" { if release.TagName == "" {
return "", nil, errors.New("No release found") return "", nil, errors.New("No release found")
} }
// if the current version is the same as the latest version, don't update
if cmd.Version == release.TagName { if cmd.Version == release.TagName {
fmt.Println("You are using the latest version") fmt.Println("You are using the latest version")
return "", nil, errors.New("You are using the latest version") return "", nil, errors.New("You are using the latest version")