diff --git a/Makefile b/Makefile index 56adca42b..eb9439e9e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,13 @@ default: build +QRI_VERSION?="0.9.14-dev" + +BUILD_FLAGS?=CGO_ENABLED=0 +PKG=$(shell go list ./version) +GOLANG_VERSION=$(shell go version | awk '{print $$3}') +GOVVV_FLAGS=$(shell govvv -flags -pkg $(PKG) -version $(QRI_VERSION)) + require-goversion: $(eval minver := go1.13) # Get the version of the current go binary @@ -18,24 +25,11 @@ require-goversion: fi; build: require-goversion - go install - -build-latest: - git checkout master && git pull - build + $(BUILD_FLAGS) go build -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} ${GOVVV_FLAGS}" . -update-qri-deps: require-gopath - cd $$GOPATH/src/github.com/qri-io/qri && git checkout master && git pull && gx install - cd $$GOPATH/src/github.com/qri-io/qfs && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/qri/registry && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/dataset && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/varName && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/deepdiff && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/jsonschema && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/starlib && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/dag && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/ioes && git checkout master && git pull - cd $$GOPATH/src/github.com/qri-io/qri +install: require-goversion + $(BUILD_FLAGS) go install -ldflags="-X ${PKG}.GolangVersion=${GOLANG_VERSION} ${GOVVV_FLAGS}" . +.PHONY: install dscache_fbs: cd dscache && flatc --go def.fbs diff --git a/api/api.go b/api/api.go index e2cb131e1..e2ac706c4 100644 --- a/api/api.go +++ b/api/api.go @@ -17,7 +17,7 @@ import ( var ( log = golog.Logger("qriapi") // APIVersion is the version string that is written in API responses - APIVersion = version.String + APIVersion = version.Version ) const ( diff --git a/cmd/version.go b/cmd/version.go index d65375d22..5bde0c673 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -19,7 +19,7 @@ For updates & further information check https://github.com/qri-io/qri/releases`, }, Args: cobra.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - printInfo(ioStreams.Out, version.String) + printInfo(ioStreams.Out, version.Summary()) return nil }, } diff --git a/go.mod b/go.mod index 5be55c74a..82cdd76b1 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/qri-io/qri go 1.13 require ( + github.com/ahmetb/govvv v0.3.0 // indirect github.com/axiomhq/hyperloglog v0.0.0-20191112132149-a4c4c47bc57f github.com/beme/abide v0.0.0-20190723115211-635a09831760 github.com/cheggaaa/pb/v3 v3.0.4 diff --git a/go.sum b/go.sum index dfd7207df..4aa607bcf 100644 --- a/go.sum +++ b/go.sum @@ -44,6 +44,8 @@ github.com/Stebalien/go-bitfield v0.0.1/go.mod h1:GNjFpasyUVkHMsfEOk8EFLJ9syQ6SI github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM= github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA= github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII= +github.com/ahmetb/govvv v0.3.0 h1:YGLGwEyiUwHFy5eh/RUhdupbuaCGBYn5T5GWXp+WJB0= +github.com/ahmetb/govvv v0.3.0/go.mod h1:4WRFpdWtc/YtKgPFwa1dr5+9hiRY5uKAL08bOlxOR6s= github.com/alangpierce/go-forceexport v0.0.0-20160317203124-8f1d6941cd75/go.mod h1:uAXEEpARkRhCZfEvy/y0Jcc888f9tHCc1W7/UeEtreE= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= diff --git a/p2p/p2p.go b/p2p/p2p.go index a7daa33da..3894e3af0 100644 --- a/p2p/p2p.go +++ b/p2p/p2p.go @@ -13,7 +13,7 @@ import ( var ( log = golog.Logger("qrip2p") // QriServiceTag marks the type & version of the qri service - QriServiceTag = fmt.Sprintf("qri/%s", version.String) + QriServiceTag = fmt.Sprintf("qri/%s", version.Version) // ErrNotConnected is for a missing required network connection ErrNotConnected = fmt.Errorf("no p2p connection") // ErrQriProtocolNotSupported is returned when a connection can't be upgraded diff --git a/remote/client.go b/remote/client.go index 0d651732c..cea697f77 100644 --- a/remote/client.go +++ b/remote/client.go @@ -741,7 +741,7 @@ func (c *client) signHTTPRequest(req *http.Request) error { req.Header.Add("timestamp", now) req.Header.Add("pid", peerID) req.Header.Add("signature", b64Sig) - req.Header.Add("qri-version", version.String) + req.Header.Add("qri-version", version.Version) return nil } diff --git a/startf/transform.go b/startf/transform.go index 1bfe08754..d964cb05f 100644 --- a/startf/transform.go +++ b/startf/transform.go @@ -23,7 +23,7 @@ import ( ) // Version is the version of qri that this transform was run with -var Version = version.String +var Version = version.Version // ExecOpts defines options for execution type ExecOpts struct { diff --git a/version/version.go b/version/version.go index 40ce8175a..f38fba7d3 100644 --- a/version/version.go +++ b/version/version.go @@ -1,4 +1,34 @@ package version -// String is the version number of qri -const String = "0.9.14-dev" +import "fmt" + +var ( + // Version is set by govvv at build time + Version = "n/a" + // GitCommit is set by govvv at build time + GitCommit = "n/a" + // GitBranch is set by govvv at build time + GitBranch = "n/a" + // GitState is set by govvv at build time + GitState = "n/a" + // GitSummary is set by govvv at build time + GitSummary = "n/a" + // BuildDate is set by govvv at build time + BuildDate = "n/a" + // GolangVersion is set by govvv at build time + GolangVersion = "n/a" +) + +// Summary prints a summary of all build info. +func Summary() string { + return fmt.Sprintf( + "version:\t%s\n\nbuild date:\t%s\ngit summary:\t%s\ngit branch:\t%s\ngit commit:\t%s\ngit state:\t%s\ngolang version:\t%s", + Version, + BuildDate, + GitSummary, + GitBranch, + GitCommit, + GitState, + GolangVersion, + ) +}