Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Add build version and a version command
Browse files Browse the repository at this point in the history
  • Loading branch information
John Esmet committed Feb 9, 2018
1 parent 39b8c10 commit f2f9488
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ REPOROOT = $(abspath $(dir $(THIS_MAKEFILE)))
TEST_PACKAGES = $(subst $(REPOROOT)/src/,,$(shell go list -f '{{if gt (len .TestGoFiles) 0}}{{.Dir}}{{end}}' ./...))

export GOPATH := $(REPOROOT)/
export VERSION ?= DEVELOPMENT
export GOCMD ?= go

.PHONY: all
Expand All @@ -16,7 +17,7 @@ clean:

.PHONY: ankh
ankh:
cd $(REPOROOT)/src/ankh/cmd/ankh; $(GOCMD) install
cd $(REPOROOT)/src/ankh/cmd/ankh; $(GOCMD) install -ldflags "-X main.AnkhBuildVersion=$(VERSION)"

.PHONY: install
install: ankh
Expand Down
8 changes: 7 additions & 1 deletion release.bash
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
#!/bin/bash

if [ -z "$VERSION" ] ; then
echo "Must provide VERSION"
exit 1
fi

make clean || exit 1

release_dir=release
mkdir -p $release_dir
rm -f $release_dir/*

function release() {
export GOOS=$1
Expand Down
7 changes: 7 additions & 0 deletions src/ankh/cmd/ankh/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
"ankh/util"
)

var AnkhBuildVersion string

var log = logrus.New()

func logExecuteAnkhFile(ctx *ankh.ExecutionContext, ankhFile ankh.AnkhFile) {
Expand Down Expand Up @@ -331,6 +333,11 @@ func main() {
})
})

app.Command("version", "Show version info", func(cmd *cli.Cmd) {
fmt.Println(AnkhBuildVersion)
os.Exit(0)
})

app.Run(os.Args)
}

Expand Down

0 comments on commit f2f9488

Please sign in to comment.