Skip to content

Commit

Permalink
resolved go-gitea#91: automatically generate gitea version
Browse files Browse the repository at this point in the history
  • Loading branch information
lunny committed Nov 7, 2016
1 parent 5a6f7ed commit c20c629
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
37 changes: 37 additions & 0 deletions make.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/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
cat /etc/passwd | read 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)
echo "$version"

tag=$(git describe --tag --always)
echo "$tag"

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

0 comments on commit c20c629

Please sign in to comment.