From 587a02562fd2ff612971355a2e662f73424c7c2e Mon Sep 17 00:00:00 2001 From: Denis Arh Date: Mon, 24 Aug 2020 15:23:49 +0200 Subject: [PATCH] Fix & tweak version & build-time info --- Makefile | 4 +--- pkg/version/version.go | 10 ++++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 90fde98a3..219620143 100644 --- a/Makefile +++ b/Makefile @@ -23,11 +23,9 @@ RELEASE_NAME = $(BUILD_NAME).tar.gz RELEASE_EXTRA_FILES ?= README.md LICENSE CONTRIBUTING.md DCO .env.example RELEASE_PKEY ?= .upload-rsa - -LDFLAGS_BUILD_TIME = -X github.com/cortezaproject/corteza-server/pkg/version.BuildTime=$(BUILD_TIME) LDFLAGS_VERSION = -X github.com/cortezaproject/corteza-server/pkg/version.Version=$(BUILD_VERSION) LDFLAGS_EXTRA ?= -LDFLAGS = -ldflags "$(LDFLAGS_BUILD_TIME) $(LDFLAGS_GIT_TAG) $(LDFLAGS_EXTRA)" +LDFLAGS = -ldflags "$(LDFLAGS_VERSION) $(LDFLAGS_EXTRA)" # Run watcher with a different event-trigger delay, eg: diff --git a/pkg/version/version.go b/pkg/version/version.go index 7b848dc99..937083c59 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -2,13 +2,19 @@ package version import ( "net/http" + "time" "github.com/titpetric/factory/resputil" ) var ( - BuildTime = "undefined" - Version = "undefined" + // BuildTime value is set at build time and served over API and CLI + BuildTime = time.Now().Format(time.RFC3339) + + // Version is set as LDFLAG at build time: + // -X github.com/cortezaproject/corteza-server/pkg/version.Version=.... + // See Makefile for details + Version = "development" ) func HttpHandler(w http.ResponseWriter, r *http.Request) {