Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit cbdb45e

Browse files
authored
Merge pull request #451 from WeiZhang555/add-commit-to-version
Show commit and version numbers
2 parents 1c3ec18 + 8627454 commit cbdb45e

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Makefile.am

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ else
1111
LIBVIRT_BUILD_TAG=
1212
endif
1313

14+
COMMIT=`git describe --dirty --always --tags 2> /dev/null || true`
15+
GOLDFLAGS="-X main.gitCommit=${COMMIT} -X main.version=${VERSION}"
1416
HYPER_BULD_TAGS=$(XEN_BUILD_TAG) $(LIBVIRT_BUILD_TAG)
17+
1518
all-local: build-runv
1619
clean-local:
1720
-rm -f runv
1821
install-exec-local:
1922
$(INSTALL_PROGRAM) runv $(bindir)
2023

2124
build-runv:
22-
go build -tags "static_build $(HYPER_BULD_TAGS)" -o runv .
25+
go build -tags "static_build $(HYPER_BULD_TAGS)" -ldflags ${GOLDFLAGS} -o runv .
2326
test-integration:
2427
cd integration-test/test_data && make
2528
cd integration-test && go test -check.v -test.timeout=120m ${TESTFLAGS} .

main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,12 @@ import (
2020
"google.golang.org/grpc/grpclog"
2121
)
2222

23+
var (
24+
version = ""
25+
gitCommit = ""
26+
)
27+
2328
const (
24-
version = "0.8.1"
2529
specConfig = "config.json"
2630
stateJson = "state.json"
2731
usage = `Open Container Initiative hypervisor-based runtime
@@ -59,7 +63,7 @@ func main() {
5963
app := cli.NewApp()
6064
app.Name = "runv"
6165
app.Usage = usage
62-
app.Version = version
66+
app.Version = fmt.Sprintf("%s, commit: %s", version, gitCommit)
6367
app.Flags = []cli.Flag{
6468
cli.BoolFlag{
6569
Name: "debug",

0 commit comments

Comments
 (0)