Merge pull request #230 from tendermint/feature/make-version

Set git commit in version for all binaries
This commit is contained in:
Ethan Frey 2017-08-18 22:25:23 +01:00 committed by GitHub
commit f04975c6a6
8 changed files with 18 additions and 37 deletions

View File

@ -3,14 +3,16 @@ GOTOOLS = github.com/mitchellh/gox \
github.com/rigelrozanski/shelldown/cmd/shelldown github.com/rigelrozanski/shelldown/cmd/shelldown
TUTORIALS=$(shell find docs/guide -name "*md" -type f) TUTORIALS=$(shell find docs/guide -name "*md" -type f)
LINKER_FLAGS:="-X github.com/tendermint/basecoin/client/commands.CommitHash=`git rev-parse --short HEAD`"
all: get_vendor_deps install test all: get_vendor_deps install test
build: build:
@go build ./cmd/... @go build ./cmd/...
install: install:
@go install ./cmd/... @go install -ldflags $(LINKER_FLAGS) ./cmd/...
@go install ./docs/guide/counter/cmd/... @go install -ldflags $(LINKER_FLAGS) ./docs/guide/counter/cmd/...
dist: dist:
@bash publish/dist.sh @bash publish/dist.sh

View File

@ -7,11 +7,14 @@ import (
"github.com/tendermint/basecoin/version" "github.com/tendermint/basecoin/version"
) )
// CommitHash should be filled by linker flags
var CommitHash = ""
// VersionCmd - command to show the application version // VersionCmd - command to show the application version
var VersionCmd = &cobra.Command{ var VersionCmd = &cobra.Command{
Use: "version", Use: "version",
Short: "Show version info", Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version) fmt.Printf("v%s %s\n", version.Version, CommitHash)
}, },
} }

View File

@ -1,29 +0,0 @@
package commands
import (
"fmt"
"github.com/spf13/cobra"
"github.com/tendermint/basecoin/version"
)
// VersionCmd - command to show the application version
var VersionCmd = &cobra.Command{
Use: "version",
Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version.Version)
},
}
// QuickVersionCmd - returns a version command based on version input
func QuickVersionCmd(version string) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Show version info",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version)
},
}
}

View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tmlibs/cli"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
client "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands"
"github.com/tendermint/basecoin/modules/auth" "github.com/tendermint/basecoin/modules/auth"
"github.com/tendermint/basecoin/modules/base" "github.com/tendermint/basecoin/modules/base"
@ -51,7 +52,7 @@ func main() {
commands.StartCmd, commands.StartCmd,
//commands.RelayCmd, //commands.RelayCmd,
commands.UnsafeResetAllCmd, commands.UnsafeResetAllCmd,
commands.VersionCmd, client.VersionCmd,
) )
cmd := cli.PrepareMainCmd(rt, "BC", os.ExpandEnv("$HOME/.basecoin")) cmd := cli.PrepareMainCmd(rt, "BC", os.ExpandEnv("$HOME/.basecoin"))

View File

@ -74,11 +74,12 @@ func main() {
srvCli.AddCommand( srvCli.AddCommand(
commands.InitCmd, commands.InitCmd,
commands.VersionCmd,
serveCmd, serveCmd,
) )
// TODO: Decide whether to use $HOME/.basecli for compatibility // this should share the dir with basecli, so you can use the cli and
// or just use $HOME/.baseserver? // the api interchangeably
cmd := cli.PrepareMainCmd(srvCli, "BC", os.ExpandEnv("$HOME/.basecli")) cmd := cli.PrepareMainCmd(srvCli, "BC", os.ExpandEnv("$HOME/.basecli"))
if err := cmd.Execute(); err != nil { if err := cmd.Execute(); err != nil {
log.Fatal(err) log.Fatal(err)

View File

@ -6,6 +6,7 @@ import (
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tmlibs/cli"
"github.com/tendermint/basecoin" "github.com/tendermint/basecoin"
client "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands"
"github.com/tendermint/basecoin/modules/base" "github.com/tendermint/basecoin/modules/base"
"github.com/tendermint/basecoin/modules/eyes" "github.com/tendermint/basecoin/modules/eyes"
@ -36,7 +37,7 @@ func main() {
InitCmd, InitCmd,
commands.StartCmd, commands.StartCmd,
commands.UnsafeResetAllCmd, commands.UnsafeResetAllCmd,
commands.VersionCmd, client.VersionCmd,
) )
cmd := cli.PrepareMainCmd(rt, "EYE", os.ExpandEnv("$HOME/.eyes")) cmd := cli.PrepareMainCmd(rt, "EYE", os.ExpandEnv("$HOME/.eyes"))

View File

@ -7,6 +7,7 @@ import (
"github.com/tendermint/tmlibs/cli" "github.com/tendermint/tmlibs/cli"
client "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/cmd/basecoin/commands" "github.com/tendermint/basecoin/cmd/basecoin/commands"
"github.com/tendermint/basecoin/docs/guide/counter/plugins/counter" "github.com/tendermint/basecoin/docs/guide/counter/plugins/counter"
) )
@ -24,7 +25,7 @@ func main() {
commands.InitCmd, commands.InitCmd,
commands.StartCmd, commands.StartCmd,
commands.UnsafeResetAllCmd, commands.UnsafeResetAllCmd,
commands.VersionCmd, client.VersionCmd,
) )
cmd := cli.PrepareMainCmd(RootCmd, "CT", os.ExpandEnv("$HOME/.counter")) cmd := cli.PrepareMainCmd(RootCmd, "CT", os.ExpandEnv("$HOME/.counter"))

View File

@ -70,6 +70,7 @@ func main() {
BaseCli.AddCommand( BaseCli.AddCommand(
commands.InitCmd, commands.InitCmd,
commands.ResetCmd, commands.ResetCmd,
commands.VersionCmd,
keycmd.RootCmd, keycmd.RootCmd,
seeds.RootCmd, seeds.RootCmd,
query.RootCmd, query.RootCmd,