diff --git a/main.go b/main.go index f077b5ec31b57..745560454560d 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ import ( ) // Version holds the current Gitea version -const Version = "0.9.99.0915" +var Version = "0.9.99.0915" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/make.bash b/make.bash new file mode 100755 index 0000000000000..0974b3a54afd0 --- /dev/null +++ b/make.bash @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +# Copyright 2016 The Gitea Authors. All rights reserved. +# Use of this source code is governed by a MIT-style +# license that can be found in the LICENSE file. + +version="unknow" + +if [ -f VERSION ]; then + version=$(cat VERSION) + go build -ldflags "-w -s -X main.Version=${version}" + exit 0 +fi + +version=$(git rev-parse --git-dir) +if [ "$version" != ".git" ]; then + echo "no VERSION found and not a git project" + exit 1 +fi + +version=$(git rev-parse --abbrev-ref HEAD) +tag=$(git describe --tag --always) + +if [ "$version" != "HEAD" ]; then + if [ "$version" == "master" ]; then + go build -ldflags "-X main.Version=tip+${tag}" + else + go build -ldflags "-X main.Version=${version}+${tag}" + fi + exit 0 +else + go build -ldflags "-X main.Version=${tag}" +fi \ No newline at end of file