File tree Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Expand file tree Collapse file tree 2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change 1- nginx-http-auth
1+ nginx-http-auth *
22conf /app.conf
33gitversion
44nohup.out
Original file line number Diff line number Diff line change @@ -8,6 +8,17 @@ pidfile=$WORKSPACE"/nginx-http-auth.pid"
88logfile=$WORKSPACE " /nginx-http-auth.log"
99conf=$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+
1122function 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
83103function 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
92111function 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
You can’t perform that action at this time.
0 commit comments