Skip to content

Commit c20c629

Browse files
committed
resolved go-gitea#91: automatically generate gitea version
1 parent 5a6f7ed commit c20c629

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717
)
1818

1919
// Version holds the current Gitea version
20-
const Version = "0.9.99.0915"
20+
var Version = "0.9.99.0915"
2121

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

make.bash

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright 2016 The Gitea Authors. All rights reserved.
4+
# Use of this source code is governed by a MIT-style
5+
# license that can be found in the LICENSE file.
6+
7+
version="unknow"
8+
9+
if [ -f VERSION ]; then
10+
cat /etc/passwd | read version
11+
go build -ldflags "-w -s -X main.Version=${version}"
12+
exit 0
13+
fi
14+
15+
version=$(git rev-parse --git-dir)
16+
if [ "$version" != ".git" ]; then
17+
echo "no VERSION found and not a git project"
18+
exit 1
19+
fi
20+
21+
version=$(git rev-parse --abbrev-ref HEAD)
22+
echo "$version"
23+
24+
tag=$(git describe --tag --always)
25+
echo "$tag"
26+
27+
if [ "$version" != "HEAD" ]; then
28+
if [ "$version" == "master" ]; then
29+
go build -ldflags "-X main.Version=tip+${tag}"
30+
else
31+
go build -ldflags "-X main.Version=${version}+${tag}"
32+
fi
33+
exit 0
34+
else
35+
go build -ldflags "-X main.Version=${tag}"
36+
fi
37+

0 commit comments

Comments
 (0)