diff --git a/Makefile.am b/Makefile.am index a4b12dae..b8544ee9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,7 +11,10 @@ else LIBVIRT_BUILD_TAG= endif +COMMIT=`git describe --dirty --always --tags 2> /dev/null || true` +GOLDFLAGS="-X main.gitCommit=${COMMIT} -X main.version=${VERSION}" HYPER_BULD_TAGS=$(XEN_BUILD_TAG) $(LIBVIRT_BUILD_TAG) + all-local: build-runv clean-local: -rm -f runv @@ -19,7 +22,7 @@ install-exec-local: $(INSTALL_PROGRAM) runv $(bindir) build-runv: - go build -tags "static_build $(HYPER_BULD_TAGS)" -o runv . + go build -tags "static_build $(HYPER_BULD_TAGS)" -ldflags ${GOLDFLAGS} -o runv . test-integration: cd integration-test/test_data && make cd integration-test && go test -check.v -test.timeout=120m ${TESTFLAGS} . diff --git a/main.go b/main.go index c9989456..633137d9 100644 --- a/main.go +++ b/main.go @@ -20,8 +20,12 @@ import ( "google.golang.org/grpc/grpclog" ) +var ( + version = "" + gitCommit = "" +) + const ( - version = "0.8.1" specConfig = "config.json" stateJson = "state.json" usage = `Open Container Initiative hypervisor-based runtime @@ -59,7 +63,7 @@ func main() { app := cli.NewApp() app.Name = "runv" app.Usage = usage - app.Version = version + app.Version = fmt.Sprintf("%s, commit: %s", version, gitCommit) app.Flags = []cli.Flag{ cli.BoolFlag{ Name: "debug",