forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolved go-gitea#91: automatically generate gitea version
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|