Skip to content

Commit 6030d00

Browse files
committed
feat: add build time version for Database Lab server and CLI (#79)
1 parent dc49cbf commit 6030d00

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ SERVER_BINARY = dblab-server
44
CLI_BINARY = dblab
55
GOARCH = amd64
66

7-
VERSION?=0.3.1
7+
COMMIT?=$(shell git rev-parse HEAD)
88
BUILD_TIME?=$(shell date -u '+%Y%m%d-%H%M')
9-
COMMIT?=no #$(shell git rev-parse HEAD)
10-
BRANCH?=no #$(shell git rev-parse --abbrev-ref HEAD)
9+
VERSION=$(shell git describe --tags 2>/dev/null || echo "${COMMIT}")
1110

1211
# Symlink into GOPATH
1312
BUILD_DIR=${GOPATH}/${SERVER_BINARY}
1413

1514
# Setup the -ldflags option for go build here, interpolate the variable values
1615
LDFLAGS = -ldflags "-s -w \
1716
-X gitlab.com/postgres-ai/database-lab/version.version=${VERSION} \
18-
-X main.commit=${COMMIT} \
19-
-X main.branch=${BRANCH}\
2017
-X gitlab.com/postgres-ai/database-lab/version.buildTime=${BUILD_TIME}"
2118

2219
# Go tooling command aliases

cmd/database-lab/main.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"gitlab.com/postgres-ai/database-lab/pkg/services/platform"
2727
"gitlab.com/postgres-ai/database-lab/pkg/services/provision"
2828
"gitlab.com/postgres-ai/database-lab/pkg/srv"
29+
"gitlab.com/postgres-ai/database-lab/version"
2930
)
3031

3132
var opts struct {
@@ -39,6 +40,8 @@ var opts struct {
3940
}
4041

4142
func main() {
43+
log.Msg("Database Lab version: ", version.GetVersion())
44+
4245
// Load CLI options.
4346
if _, err := parseArgs(); err != nil {
4447
if flags.WroteHelp(err) {

0 commit comments

Comments
 (0)