Skip to content

Commit 3a1e1bc

Browse files
Expose server version tag to be set during build time
1 parent f50a0fe commit 3a1e1bc

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

cmd/server/cadence/cadence.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ func constructPathIfNeed(dir string, file string) string {
158158
}
159159

160160
// BuildCLI is the main entry point for the cadence server
161-
func BuildCLI() *cli.App {
161+
func BuildCLI(version string, revision string) *cli.App {
162162

163163
app := cli.NewApp()
164164
app.Name = "cadence"
165165
app.Usage = "Cadence server"
166-
app.Version = "0.0.1"
166+
app.Version = version + "-" + revision
167167

168168
app.Flags = []cli.Flag{
169169
cli.StringFlag{

cmd/server/main.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,13 @@ import (
2424
"os"
2525

2626
"github.com/uber/cadence/cmd/server/cadence"
27+
"github.com/uber/cadence/common/metrics"
2728
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/mysql" // needed to load mysql plugin
2829
_ "github.com/uber/cadence/common/persistence/sql/sqlplugin/postgres" // needed to load postgres plugin
2930
)
3031

3132
// main entry point for the cadence server
3233
func main() {
33-
app := cadence.BuildCLI()
34+
app := cadence.BuildCLI(metrics.Version, metrics.Revision)
3435
app.Run(os.Args)
3536
}

scripts/go-build-ldflags.sh

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ fi
99

1010
export GIT_REVISION=$(git rev-parse --short HEAD)
1111
export GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
12-
export GIT_VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo unknown)
1312
export BUILD_DATE=$(date '+%F-%T') # outputs something in this format 2017-08-21-18:58:45
1413
export BUILD_TS_UNIX=$(date '+%s') # second since epoch
1514
export BASE_PACKAGE=github.com/uber/cadence/common/metrics
15+
if [ -z ${SERVER_VERSION} ]; then
16+
# If not set SERVER_VERSION, then use the most recent tag.
17+
export GIT_VERSION=$(git describe --tags --abbrev=0 --dirty 2>/dev/null || echo unknown)
18+
else
19+
# If passing a version explicitly, then use it
20+
export GIT_VERSION=${SERVER_VERSION}
21+
fi
22+
1623

1724
if [ "$MODE" = "LDFLAG" ]; then
1825
LD_FLAGS="-X ${BASE_PACKAGE}.Revision=${GIT_REVISION} \

0 commit comments

Comments
 (0)