From 7de26a462fac0c31c13be94cbf9e01eb8b01529d Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 2 Mar 2020 20:24:26 +0100 Subject: [PATCH] Add build time to compile flags --- Makefile | 2 +- pkg/cmd/version.go | 3 ++- pkg/cmd/web.go | 2 +- pkg/version/version.go | 3 +++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 3ad16b28..d72095ef 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,7 @@ GOFMT ?= gofmt -s GOFLAGS := -v -mod=vendor EXTRA_GOFLAGS ?= -LDFLAGS := -X "code.vikunja.io/api/pkg/version.Version=$(shell git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')" -X "main.Tags=$(TAGS)" +LDFLAGS := -X "code.vikunja.io/api/pkg/version.Version=$(shell git describe --tags --always --abbrev=10 | sed 's/-/+/' | sed 's/^v//' | sed 's/-g/-/')" -X "main.Tags=$(TAGS)" -X "code.vikunja.io/api/pkg/version.BuildTime=$(shell date -R)" PACKAGES ?= $(filter-out code.vikunja.io/api/pkg/integrations,$(shell go list -mod=vendor ./... | grep -v /vendor/)) SOURCES ?= $(shell find . -name "*.go" -type f) diff --git a/pkg/cmd/version.go b/pkg/cmd/version.go index c3d43ae3..cb3c5fca 100644 --- a/pkg/cmd/version.go +++ b/pkg/cmd/version.go @@ -30,6 +30,7 @@ var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version number of Vikunja", Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Vikunja api version " + version.Version) + fmt.Printf("Vikunja api version %s\n", version.Version) + fmt.Printf("Built at %s\n", version.BuildTime) }, } diff --git a/pkg/cmd/web.go b/pkg/cmd/web.go index f38cf1e3..e264f7be 100644 --- a/pkg/cmd/web.go +++ b/pkg/cmd/web.go @@ -39,7 +39,7 @@ var webCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { // Version notification - log.Infof("Vikunja version %s", version.Version) + log.Infof("Vikunja version %s, built at %s", version.Version, version.BuildTime) // Additional swagger information swagger.SwaggerInfo.Version = version.Version diff --git a/pkg/version/version.go b/pkg/version/version.go index 6e55a28b..f0b55a16 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -21,3 +21,6 @@ package version // Version sets the version to be printed to the user. Gets overwritten by "make release" or "make build" with last git commit or tag. var Version = "0.7" + +// BuildTime contains the build time of vikunja. +var BuildTime = ""