File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
#
3
3
#
4
+ RELEASE_VERSION=" 0.7.2"
4
5
5
6
buildpath=/tmp/gh-ost
6
7
target=gh-ost
7
8
timestamp=$( date " +%Y%m%d%H%M%S" )
8
9
mkdir -p ${buildpath}
9
- gobuild=" go build -o $buildpath /$target go/cmd/gh-ost/main.go"
10
+ ldflags=" -X main.AppVersion=${RELEASE_VERSION} "
11
+ gobuild=" go build -ldflags \" $ldflags \" -o $buildpath /$target go/cmd/gh-ost/main.go"
10
12
11
13
echo " Building OS/X binary"
12
14
echo " GO15VENDOREXPERIMENT=1 GOOS=darwin GOARCH=amd64 $gobuild " | bash
Original file line number Diff line number Diff line change @@ -15,6 +15,8 @@ import (
15
15
"github.com/outbrain/golib/log"
16
16
)
17
17
18
+ var AppVersion string
19
+
18
20
// main is the application's entry point. It will either spawn a CLI or HTTP itnerfaces.
19
21
func main () {
20
22
migrationContext := base .GetMigrationContext ()
@@ -57,13 +59,22 @@ func main() {
57
59
debug := flag .Bool ("debug" , false , "debug mode (very verbose)" )
58
60
stack := flag .Bool ("stack" , false , "add stack trace upon error" )
59
61
help := flag .Bool ("help" , false , "Display usage" )
62
+ version := flag .Bool ("version" , false , "Print version & exit" )
60
63
flag .Parse ()
61
64
62
65
if * help {
63
66
fmt .Fprintf (os .Stderr , "Usage of gh-ost:\n " )
64
67
flag .PrintDefaults ()
65
68
return
66
69
}
70
+ if * version {
71
+ appVersion := AppVersion
72
+ if appVersion == "" {
73
+ appVersion = "unversioned"
74
+ }
75
+ fmt .Println (appVersion )
76
+ return
77
+ }
67
78
68
79
log .SetLevel (log .ERROR )
69
80
if * verbose {
@@ -106,7 +117,7 @@ func main() {
106
117
log .Fatale (err )
107
118
}
108
119
109
- log .Info ("starting gh-ost" )
120
+ log .Info ("starting gh-ost %+v" , AppVersion )
110
121
111
122
migrator := logic .NewMigrator ()
112
123
err := migrator .Migrate ()
You can’t perform that action at this time.
0 commit comments