7 Commits

Author SHA1 Message Date
b247d3dfec Add signature generation
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 17:08:24 +01:00
e36be96f4f Prettier print statement
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:49:03 +01:00
6d239c5326 Actually use gitea source
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:47:48 +01:00
4a902c2f16 No replacemnets in names for release
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:44:02 +01:00
b327d998c9 up alias
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:41:31 +01:00
d81fbc64ef Handle update error
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:40:57 +01:00
e560cf14ed Fix gitignore
Signed-off-by: Lukas Bachschwell <lukas@lbsfilm.at>
2021-01-09 16:35:47 +01:00
3 changed files with 36 additions and 11 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
gitinfo.go gitinfo.go
dist

View File

@ -12,12 +12,6 @@ builds:
- windows - windows
- darwin - darwin
archives: archives:
- replacements:
darwin: Darwin
linux: Linux
windows: Windows
386: i386
amd64: x86_64
checksum: checksum:
name_template: 'checksums.txt' name_template: 'checksums.txt'
snapshot: snapshot:
@ -28,6 +22,22 @@ changelog:
exclude: exclude:
- '^docs:' - '^docs:'
- '^test:' - '^test:'
signs:
- id: selfupdatesign
# path to the signature command
#
# defaults to `gpg`
cmd: openssl
# command line templateable arguments for the command
#
# to sign with a specific key use
# args: ["-u", "<key id, fingerprint, email, ...>", "--output", "${signature}", "--detach-sign", "${artifact}"]
#
# defaults to `["--output", "${signature}", "--detach-sign", "${artifact}"]`
args: ["dgst", "-sha256", "-sign", "privkey.pem", "${artifact}.sig", "${artifact}"]
artifacts: all
gitea_urls: gitea_urls:
api: https://git.lbsfilm.at/api/v1/ api: https://git.lbsfilm.at/api/v1/
download: https://git.lbsfilm.at download: https://git.lbsfilm.at

24
main.go
View File

@ -18,9 +18,14 @@ func main() {
if len(os.Args) < 2 { if len(os.Args) < 2 {
fmt.Println("provide a command") fmt.Println("provide a command")
os.Exit(1) os.Exit(1)
} else if os.Args[1] == "upgrade" { } else if os.Args[1] == "upgrade" || os.Args[1] == "up" {
fmt.Print("Trying Upgrade... ") fmt.Println("Trying Upgrade... ")
update(gitTag) err := update(gitTag)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Success")
}
} else if os.Args[1] == "version" { } else if os.Args[1] == "version" {
fmt.Print("Version ") fmt.Print("Version ")
fmt.Println(gitTag) fmt.Println(gitTag)
@ -30,7 +35,16 @@ func main() {
} }
func update(version string) error { 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 { if err != nil {
return fmt.Errorf("error occurred while detecting version: %v", err) return fmt.Errorf("error occurred while detecting version: %v", err)
} }
@ -47,7 +61,7 @@ func update(version string) error {
if err != nil { if err != nil {
return errors.New("could not locate executable path") 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) return fmt.Errorf("error occurred while updating binary: %v", err)
} }
log.Printf("Successfully updated to version %s", latest.Version()) log.Printf("Successfully updated to version %s", latest.Version())