add automatic version string based on git-describe (tags)

This commit is contained in:
Larry Ruane 2020-03-31 21:53:49 -06:00 committed by Larry Ruane
parent 46edad2748
commit 2fe2d9ac62
5 changed files with 8 additions and 4 deletions

View File

@ -120,10 +120,10 @@ dep:
# Build binary
build:
GO111MODULE=on go build
GO111MODULE=on go build -ldflags="-X github.com/zcash/lightwalletd/common.Version=`git describe --tags`"
build_rel:
GO111MODULE=on GOOS=linux go build
GO111MODULE=on GOOS=linux go build -ldflags="-X github.com/zcash/lightwalletd/common.Version=`git describe --tags`"
# Install binaries into Go path
install:

View File

@ -182,7 +182,7 @@ func startServer(opts *common.Options) error {
os.Exit(1)
}()
common.Log.Infof("Starting gRPC server on %s", opts.BindAddr)
common.Log.Infof("Starting gRPC server version %s on %s", common.Version, opts.BindAddr)
err = server.Serve(listener)
if err != nil {

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/spf13/cobra"
"github.com/zcash/lightwalletd/common"
)
// versionCmd represents the version command
@ -12,6 +13,6 @@ var versionCmd = &cobra.Command{
Short: "Dispaly lightwalletd version",
Long: `Dispaly lightwalletd version.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("lightwalletd version v0.2.0")
fmt.Println("lightwalletd version", common.Version)
},
}

BIN
common/__debug_bin Executable file

Binary file not shown.

View File

@ -16,6 +16,9 @@ import (
"github.com/zcash/lightwalletd/walletrpc"
)
// 'make build' will overwrite this string with the output of git-describe (tag)
var Version = "v0.0.0.0-dev"
type Options struct {
BindAddr string `json:"bind_address,omitempty"`
TLSCertPath string `json:"tls_cert_path,omitempty"`