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
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
build:
@go build ./cmd/...
install:
@go install ./cmd/...
@go install ./docs/guide/counter/cmd/...
@go install -ldflags $(LINKER_FLAGS) ./cmd/...
@go install -ldflags $(LINKER_FLAGS) ./docs/guide/counter/cmd/...
dist:
@bash publish/dist.sh

View File

@ -7,11 +7,14 @@ import (
"github.com/tendermint/basecoin/version"
)
// CommitHash should be filled by linker flags
var CommitHash = ""
// 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)
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/basecoin"
client "github.com/tendermint/basecoin/client/commands"
"github.com/tendermint/basecoin/cmd/basecoin/commands"
"github.com/tendermint/basecoin/modules/auth"
"github.com/tendermint/basecoin/modules/base"
@ -51,7 +52,7 @@ func main() {
commands.StartCmd,
//commands.RelayCmd,
commands.UnsafeResetAllCmd,
commands.VersionCmd,
client.VersionCmd,
)
cmd := cli.PrepareMainCmd(rt, "BC", os.ExpandEnv("$HOME/.basecoin"))

View File

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

View File

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

View File

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

View File

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