Add build time to compile flags

This commit is contained in:
kolaente 2020-03-02 20:24:26 +01:00
parent f2f17b11e8
commit 7de26a462f
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
4 changed files with 7 additions and 3 deletions

View file

@ -19,7 +19,7 @@ GOFMT ?= gofmt -s
GOFLAGS := -v -mod=vendor GOFLAGS := -v -mod=vendor
EXTRA_GOFLAGS ?= 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/)) PACKAGES ?= $(filter-out code.vikunja.io/api/pkg/integrations,$(shell go list -mod=vendor ./... | grep -v /vendor/))
SOURCES ?= $(shell find . -name "*.go" -type f) SOURCES ?= $(shell find . -name "*.go" -type f)

View file

@ -30,6 +30,7 @@ var versionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Print the version number of Vikunja", Short: "Print the version number of Vikunja",
Run: func(cmd *cobra.Command, args []string) { 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)
}, },
} }

View file

@ -39,7 +39,7 @@ var webCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
// Version notification // Version notification
log.Infof("Vikunja version %s", version.Version) log.Infof("Vikunja version %s, built at %s", version.Version, version.BuildTime)
// Additional swagger information // Additional swagger information
swagger.SwaggerInfo.Version = version.Version swagger.SwaggerInfo.Version = version.Version

View file

@ -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. // 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" var Version = "0.7"
// BuildTime contains the build time of vikunja.
var BuildTime = ""