feat: upgrade command

This commit is contained in:
2025-02-16 09:44:31 +01:00
parent f33ccec5c4
commit 14ff2efa3d
6 changed files with 183 additions and 0 deletions

6
utils/constants.go Normal file
View File

@ -0,0 +1,6 @@
package utils
var (
Version string
GithubReleaseUrl = "https://api.github.com/repos/CyberL1/holesail-proxy/releases/latest"
)

12
utils/types.go Normal file
View File

@ -0,0 +1,12 @@
package utils
type GithubRelease struct {
TagName string `json:"tag_name"`
Prerelease bool
}
type GithubFile struct {
Name string `json:"name"`
Path string `json:"path"`
DownloadUrl string `json:"download_url"`
}

24
utils/version.go Normal file
View File

@ -0,0 +1,24 @@
package utils
import (
"encoding/json"
"io"
"net/http"
)
func GetLatestCliVersion() (*GithubRelease, error) {
resp, err := http.Get(GithubReleaseUrl)
if err != nil {
return nil, err
}
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
release := &GithubRelease{}
err = json.Unmarshal(body, release)
if err != nil {
return nil, err
}
return release, nil
}