fix updating

This commit is contained in:
2025-07-24 08:47:36 -07:00
parent eafc55f67c
commit 87cab281ac
5 changed files with 15 additions and 7 deletions

View File

@@ -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
}