diff --git a/circle.yml b/circle.yml index 8bed18b..f915c43 100644 --- a/circle.yml +++ b/circle.yml @@ -7,7 +7,7 @@ jobs: steps: - checkout - run: go get -t -d -v ./... - - run: go install github.com/FreifunkBremen/yanic + - run: go install -ldflags "-X github.com/FreifunkBremen/yanic/cmd.VERSION=`git -C $GOPATH/src/github.com/FreifunkBremen/yanic rev-parse HEAD`" github.com/FreifunkBremen/yanic - store_artifacts: path: /go/bin/ destination: yanic diff --git a/cmd/version.go b/cmd/version.go new file mode 100644 index 0000000..3c8683d --- /dev/null +++ b/cmd/version.go @@ -0,0 +1,25 @@ +package cmd + +import ( + "fmt" + + "github.com/spf13/cobra" +) + +var VERSION string + +// versionCMD to print version +var versionCMD = &cobra.Command{ + Use: "version", + Short: "print version of yanic", + Run: func(cmd *cobra.Command, args []string) { + + fmt.Printf("yanic version: %s\n", VERSION) + }, +} + +func init() { + if VERSION != "" { + RootCmd.AddCommand(versionCMD) + } +}