Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autogenerate Version on build #190

Merged
merged 11 commits into from
Dec 13, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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//')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpicking, you should be able to group the sed calls: sed 's/^v//;s/-/+/'

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@strk that depends entirely on the version of sed unfortunately... FreeBSD for example doesn't handle that 😒

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just keep it like it is. The v replacement can even be done with plain bash ;)


LDFLAGS += -X "main.Version=$(VERSION)"

TARGETS ?= linux/*,darwin/*,windows/*
PACKAGES ?= $(shell go list ./... | grep -v /vendor/)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

// Version holds the current Gitea version
const Version = "0.9.99.0915"
var Version = "1.0.0+dev"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Var Version = "0.9.0+dev" is better. So that if user go get then the version is shown it's a dev version.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can either generate it, OR set it, otherwise generating it is pointless

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I do in other projects is always set the target version for each branch (ie: <next version>-alpha) and then separately and optionally append a changeset identifier which is generated on "make". As Go doesn't let us autogenerate things such setup would result in <next version>-alpha resulting in go obtained builds and <next version>-alpha+<metadata> resulting from builds via make.


func init() {
runtime.GOMAXPROCS(runtime.NumCPU())
Expand Down
9 changes: 0 additions & 9 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion templates/.VERSION

This file was deleted.