feat(cli): --version using ldflags

The go-modules approach is a bit broken: https://github.com/golang/go/issues/29228
To resolve that, we now compute that version using `git describe` and
set it using `ldflags`.

While this is not as nice/builtin as the other approach, it at least
works all the time and across go versions.

Furthermore, I did refactor the Makefile in preparation for an AUR
package that builds from source and for building release artifacts in CI.
This commit is contained in:
sh0rez 2020-02-28 19:40:37 +01:00
parent f8be6a936f
commit 80c06a483a
No known key found for this signature in database
GPG key ID: 87C71DF9F8181FF1
4 changed files with 37 additions and 83 deletions

View file

@ -21,6 +21,7 @@ import (
"github.com/fatih/color"
"github.com/pkg/errors"
"gopkg.in/alecthomas/kingpin.v2"
)
const (
@ -30,6 +31,8 @@ const (
rewriteActionName = "rewrite"
)
var Version = "dev"
func main() {
os.Exit(Main())
}
@ -41,7 +44,7 @@ func Main() int {
color.Output = color.Error
a := newApp()
a := kingpin.New(filepath.Base(os.Args[0]), "A jsonnet package manager").Version(Version)
a.HelpFlag.Short('h')
a.Flag("jsonnetpkg-home", "The directory used to cache packages in.").