Gitrel - Github Release Updater for Go
This library been replaced by ghru - please use that project instead.
Gitrel is a package for golang to allow binary updating from the latest release assets on Github.
It downloads pre-compiled binaries from your latest release, and replaces the current running version.
Binaries must be attached to your latest Github release (assets), compressed with bzip2 (bz2
),
and named accordingly: <name>_<version>_<os>_<architecture>.bz2
, eg:
myapp_1.2.3_linux_amd64.bz2
myapp_1.2.3_linux_386.bz2
myapp_1.2.3_darwin_386.bz2
myapp_1.2.3_darwin_amd64.bz2
myapp_1.2.3_windows_amd64.exe.bz2
myapp_1.2.3_windows_386.exe.bz2
Gitrel does not compare semantic versioning, so it will always assume that if the latest release version on
Github differs from the current version, then it is an update. If an update is run and the application
version matches the latest release tag, then the update is skipped. If an update is available
however Gitrel cannot find a match of release asset (ie: operating system and artitecture), then the
update is aborted. It does not matter what the running binary is called, it will be updated provided the
user running the update has permissions to read & write to the running binary and binary directory.
Install
go get -u github.com/axllent/gitrel
Example usage
The update command is gitrel.Update("myuser/myapp", "myapp", currentVersion)
, where:
myuser/myapp
is your github name (handle) and the repo name
myapp
is the name of your app for your binaries (generally the same as the repo)
currentVersion
is the version of the running application
How you define your current running version is entirely up to you, but you must provide it otherwise
Gitrel cannot compare with the latest release.
package main
import (
"flag"
"fmt"
"log"
"github.com/axllent/gitrel"
)
func main() {
update := flag.Bool("u", false, "updater to latest release")
flag.Parse()
var currentVersion = "0.1.2"
if *update {
rel, err := gitrel.Update("myuser/myapp", "myapp", currentVersion)
if err != nil {
log.Fatal(err)
return
}
fmt.Printf("Updated %s to version %s\n", os.Args[0], rel)
return
}
}