Description
Certain projects use the release tag in the archive name, eg awesome-package_0.1.2_linux_amd64.tar.gz
, and I seem to recall some that even use it in the binary name too (not that I think the latter is a good idea).
My suggestion is to allow some basic go templating on both the Provider ArchiveName
and Updater .ExecutableName
of at least some common variables, such as {{.Tag}}
{{.GOOS}}&
{{.GOARCH}}. Whilst certain variables can be generated before the request (
runtime.GOOS&
runtime.GOARCH`), others are dependent on the remote info.
u := &updater.Updater{
Provider: &provider.Github{
RepositoryURL: "github.com/user/awesome-package",
ArchiveName: `awesome-package_{{.Tag}}_{{.GOOS}}_{{.GOARCH}}`,
},
ExecutableName: "awesome-package_{{.Tag}}",
Version: "0.1.1",
}
This would of course still remain completely backwards compatible with the current system, and one could even mix the two: ArchiveName: fmt.Sprintf("awesome-package_{{.Tag}}_%s_%s.tar.gz", runtime.GOOS, runtime.GOARCH)
.
The backstory is I've been meaning to rewrite a simple GitHub binary updater I wrote some time ago (far more primitive than yours), although I have been putting it off while I collect ideas etc. I just came across go-rocket-update
which I think has a lot of potential, so rather than me spend time rewriting mine from scratch, I'd first check to see if you were open to suggestions to yours instead? I also have some other suggestions too if you're open to it.