Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
e36be96f4f
|
|||
6d239c5326
|
|||
4a902c2f16
|
|||
b327d998c9
|
|||
d81fbc64ef
|
|||
e560cf14ed
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -1 +1,2 @@
|
||||
gitinfo.go
|
||||
dist
|
||||
|
@ -12,12 +12,6 @@ builds:
|
||||
- windows
|
||||
- darwin
|
||||
archives:
|
||||
- replacements:
|
||||
darwin: Darwin
|
||||
linux: Linux
|
||||
windows: Windows
|
||||
386: i386
|
||||
amd64: x86_64
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
snapshot:
|
||||
|
24
main.go
24
main.go
@ -18,9 +18,14 @@ func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("provide a command")
|
||||
os.Exit(1)
|
||||
} else if os.Args[1] == "upgrade" {
|
||||
fmt.Print("Trying Upgrade... ")
|
||||
update(gitTag)
|
||||
} else if os.Args[1] == "upgrade" || os.Args[1] == "up" {
|
||||
fmt.Println("Trying Upgrade... ")
|
||||
err := update(gitTag)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
} else {
|
||||
fmt.Println("Success")
|
||||
}
|
||||
} else if os.Args[1] == "version" {
|
||||
fmt.Print("Version ")
|
||||
fmt.Println(gitTag)
|
||||
@ -30,7 +35,16 @@ func main() {
|
||||
}
|
||||
|
||||
func update(version string) error {
|
||||
latest, found, err := selfupdate.DetectLatest("lbsadmin/goselfupdatetest")
|
||||
source, _ := selfupdate.NewGiteaSource(selfupdate.GiteaConfig{BaseURL: "https://git.lbsfilm.at/"})
|
||||
updater, err := selfupdate.NewUpdater(selfupdate.Config{
|
||||
Source: source,
|
||||
Validator: nil,
|
||||
OS: runtime.GOOS,
|
||||
Arch: runtime.GOARCH,
|
||||
Arm: 0,
|
||||
})
|
||||
|
||||
latest, found, err := updater.DetectLatest("lbsadmin/goselfupdatetest")
|
||||
if err != nil {
|
||||
return fmt.Errorf("error occurred while detecting version: %v", err)
|
||||
}
|
||||
@ -47,7 +61,7 @@ func update(version string) error {
|
||||
if err != nil {
|
||||
return errors.New("could not locate executable path")
|
||||
}
|
||||
if err := selfupdate.UpdateTo(latest.AssetURL, latest.AssetName, exe); err != nil {
|
||||
if err := updater.UpdateTo(latest, exe); err != nil {
|
||||
return fmt.Errorf("error occurred while updating binary: %v", err)
|
||||
}
|
||||
log.Printf("Successfully updated to version %s", latest.Version())
|
||||
|
Reference in New Issue
Block a user