From 1d1c01875dc4f07b204a40aa662aa1782bf000fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kim=20=22BKC=22=20Carlb=C3=A4cker?= Date: Tue, 13 Dec 2016 05:48:58 +0100 Subject: [PATCH] Autogenerate Version on build (#190) * Autogenerate Version On Build * Fixes * Changed Version to v0.9.0 * balls * I hate newlines * Don't remove .VERSION-file on `make clean` * v0.9.0 => 1.0.0 * damn new-lines... * Always rebuild templates/.VERSION * Delete .VERSION * Update Makefile --- Makefile | 5 +++-- main.go | 2 +- modules/setting/setting.go | 9 --------- 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 75aef7f3cf..ae049d0086 100644 --- a/Makefile +++ b/Makefile @@ -9,8 +9,9 @@ BINDATA := $(shell find conf | sed 's/ /\\ /g') STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less) JAVASCRIPTS := -LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildTime=$(DATE)" -LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildGitHash=$(SHA)" +VERSION = $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//') + +LDFLAGS += -X "main.Version=$(VERSION)" TARGETS ?= linux/*,darwin/*,windows/* PACKAGES ?= $(shell go list ./... | grep -v /vendor/) diff --git a/main.go b/main.go index 3383400082..620378491a 100644 --- a/main.go +++ b/main.go @@ -18,7 +18,7 @@ import ( ) // Version holds the current Gitea version -const Version = "0.9.99.0915" +var Version = "1.0.0+dev" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 7e3bfb47ba..ece149a0ce 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -53,10 +53,6 @@ const ( // settings var ( - // BuildTime information should only be set by -ldflags. - BuildTime string - BuildGitHash string - // AppVer settings AppVer string AppName string @@ -642,11 +638,6 @@ var logLevels = map[string]string{ func newLogService() { log.Info("%s %s", AppName, AppVer) - if len(BuildTime) > 0 { - log.Info("Build Time: %s", BuildTime) - log.Info("Build Git Hash: %s", BuildGitHash) - } - // Get and check log mode. LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",") LogConfigs = make([]string, len(LogModes))