@@ -5,6 +5,7 @@ import (
|
||||
"epochsilicon/pkg/log"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -161,7 +162,7 @@ type Asset struct {
|
||||
}
|
||||
|
||||
// CheckForUpdateWithAssets returns update information including download assets
|
||||
func CheckForUpdateWithAssets(currentVersion string) (*UpdateInfo, bool, error) {
|
||||
func CheckForUpdateWithAssets(currentVersion *semver.Version) (*UpdateInfo, bool, error) {
|
||||
resp, err := http.Get("https://git.burkey.co/api/v1/repos/eburk/epochsilicon/releases/latest")
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
@@ -191,8 +192,11 @@ func CheckForUpdateWithAssets(currentVersion string) (*UpdateInfo, bool, error)
|
||||
return nil, false, fmt.Errorf("failed to parse JSON response: %v. Response: %s", err, bodyStr[:min(200, len(bodyStr))])
|
||||
}
|
||||
|
||||
latest := strings.TrimPrefix(updateInfo.TagName, "v")
|
||||
updateAvailable := latest != currentVersion
|
||||
latest, err := semver.NewVersion(updateInfo.TagName)
|
||||
if err != nil {
|
||||
return nil, false, fmt.Errorf("failed to parse semver: %v", err)
|
||||
}
|
||||
updateAvailable := latest.GreaterThan(currentVersion)
|
||||
|
||||
return &updateInfo, updateAvailable, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user