Skip to content

Commit 8434519

Browse files
committed
Updated control script
1 parent 443143c commit 8434519

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
nginx-http-auth
1+
nginx-http-auth*
22
conf/app.conf
33
gitversion
44
nohup.out

control

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ pidfile=$WORKSPACE"/nginx-http-auth.pid"
88
logfile=$WORKSPACE"/nginx-http-auth.log"
99
conf=$WORKSPACE"/conf/app.conf"
1010

11+
version="0.1.0"
12+
function get_version() {
13+
ver=`git tag | tail -n1`
14+
if [ $? -ne 0 ]; then
15+
echo "not a git repo"
16+
exit 1
17+
elif [ ! -z $ver ]; then
18+
version=$ver
19+
fi
20+
}
21+
1122
function check_pid() {
1223
if [ -f $pidfile ];then
1324
pid=`cat $pidfile`
@@ -67,6 +78,15 @@ function build() {
6778
cd $WORKSPACE
6879
echo $1
6980

81+
[ -d g ] || mkdir g
82+
get_version
83+
cat > g/version.go << EOF
84+
package g
85+
86+
const (
87+
VERSION = "$version"
88+
)
89+
EOF
7090
if [ "$1" == "linux" ] ;then
7191
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build
7292
elif [ "$1" == "windows" ] ;then
@@ -81,18 +101,16 @@ function build() {
81101
}
82102

83103
function pack() {
84-
build $1
85104
git log -1 --pretty=%h > gitversion
86-
version=`$app -v`
87-
file_list="nginx-http-auth static views control conf/app.example.conf conf/nginx.conf"
105+
get_version
106+
file_list="nginx-http-auth static views control conf/app.example.conf conf/nginx.example.conf"
88107
echo "...tar $app-$version.tar.gz <= $file_list"
89108
tar zcf $app-$version.tar.gz gitversion $file_list
90109
}
91110

92111
function packbin() {
93-
build $1
94112
git log -1 --pretty=%h > gitversion
95-
version=`$app -v`
113+
get_version
96114
tar zcvf $app-bin-$version.tar.gz nginx-http-auth gitversion
97115
}
98116

0 commit comments

Comments
 (0)