Skip to content

Commit

Permalink
U: cli -u
Browse files Browse the repository at this point in the history
  • Loading branch information
sxmxta committed Dec 24, 2024
1 parent 6265595 commit fe648b2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
./build.bat
./compress-zip.bat
mv md5.txt D:/clis
mv energy-*.zip D:/clis
shell: bash

Expand Down
25 changes: 15 additions & 10 deletions cmd/internal/cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@ func CheckVersion() string {
if err := version(); err != nil {
return ""
}
term.Section.Println("CLI Current:", fmt.Sprintf("%d.%d.%d", term.Major, term.Minor, term.Build))
term.Section.Println("CLI Latest :", fmt.Sprintf("%d.%d.%d", remoteVersion.Major, remoteVersion.Minor, remoteVersion.Build))
term.Section.Println("CLI Current:", fmt.Sprintf("v%d.%d.%d", term.Major, term.Minor, term.Build))
remoteVer := fmt.Sprintf("v%d.%d.%d", remoteVersion.Major, remoteVersion.Minor, remoteVersion.Build)
term.Section.Println("CLI Latest :", remoteVer)
cv, err := strconv.Atoi(fmt.Sprintf("%d%d%d", term.Major, term.Minor, term.Build))
if err != nil {
term.Logger.Error("Check cli version failed: " + err.Error())
Expand All @@ -55,13 +56,16 @@ func CheckVersion() string {
return ""
}
if cv < rv {
// 先这样,以后在规范名字
// 下载 URL 规则:
// https://sourceforge.net/projects/energye/files/vx.x.x/energy-[os][arch].zip
// https://github.com/energye/energy/releases/download/vx.x.x/energy-[os][arch].zip
// https://gitee.com/energye/energy/releases/download/vx.x.x/energy-[os][arch].zip
cliName := CliFileName() + ".zip"
downloadURL := remoteVersion.DownloadURL
if strings.LastIndex(downloadURL, "/") != len(downloadURL) {
downloadURL += "/"
}
downloadURL = downloadURL + cliName
downloadURL = fmt.Sprintf("%v%v/%v", downloadURL, remoteVer, cliName)
term.Section.Println("There new version available.\n Download:", downloadURL)
return downloadURL
}
Expand All @@ -70,13 +74,14 @@ func CheckVersion() string {

func CliFileName() string {
cliName := consts.ENERGY + "-" + runtime.GOOS
if consts.IsARM64 {
cliName += "arm"
}
if consts.IsWindows && consts.Is386 {
cliName += "-32"
arch := runtime.GOARCH
if arch == "amd64" {
cliName += "64"
} else if arch == "386" {
cliName += "32"
} else {
cliName += "-64"
// arm64, arm
cliName += arch
}
return cliName
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/internal/remotecfg/cmd_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type TCMDVersion struct {
Major int32 `json:"major"`
Minor int32 `json:"minor"`
Build int32 `json:"build"`
DownloadURL string `json:"downloadUrl"`
DownloadURL string `json:"vDownloadUrl"`
}

func CMDVersion() (*TCMDVersion, error) {
Expand Down

0 comments on commit fe648b2

Please sign in to comment.