Skip to content

Commit 1d1c018

Browse files
bkcsoftlunny
authored andcommitted
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
1 parent f0a989c commit 1d1c018

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ BINDATA := $(shell find conf | sed 's/ /\\ /g')
99
STYLESHEETS := $(wildcard public/less/index.less public/less/_*.less)
1010
JAVASCRIPTS :=
1111

12-
LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildTime=$(DATE)"
13-
LDFLAGS += -X "code.gitea.io/gitea/modules/setting.BuildGitHash=$(SHA)"
12+
VERSION = $(shell git describe --tags --always | sed 's/-/+/' | sed 's/^v//')
13+
14+
LDFLAGS += -X "main.Version=$(VERSION)"
1415

1516
TARGETS ?= linux/*,darwin/*,windows/*
1617
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)

main.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
)
1919

2020
// Version holds the current Gitea version
21-
const Version = "0.9.99.0915"
21+
var Version = "1.0.0+dev"
2222

2323
func init() {
2424
runtime.GOMAXPROCS(runtime.NumCPU())

modules/setting/setting.go

-9
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,6 @@ const (
5353

5454
// settings
5555
var (
56-
// BuildTime information should only be set by -ldflags.
57-
BuildTime string
58-
BuildGitHash string
59-
6056
// AppVer settings
6157
AppVer string
6258
AppName string
@@ -642,11 +638,6 @@ var logLevels = map[string]string{
642638
func newLogService() {
643639
log.Info("%s %s", AppName, AppVer)
644640

645-
if len(BuildTime) > 0 {
646-
log.Info("Build Time: %s", BuildTime)
647-
log.Info("Build Git Hash: %s", BuildGitHash)
648-
}
649-
650641
// Get and check log mode.
651642
LogModes = strings.Split(Cfg.Section("log").Key("MODE").MustString("console"), ",")
652643
LogConfigs = make([]string, len(LogModes))

0 commit comments

Comments
 (0)