Add version stamp to binary and include in heartbeat
This commit is contained in:
parent
83de7325c4
commit
6d555789d6
6
Makefile
6
Makefile
|
@ -9,6 +9,8 @@ PREFIX ?= /usr/local
|
||||||
OUT = build
|
OUT = build
|
||||||
BIN = $(OUT)/bin
|
BIN = $(OUT)/bin
|
||||||
|
|
||||||
|
VERSION = $(shell git describe --tags --dirty)
|
||||||
|
|
||||||
.PHONY: dirs
|
.PHONY: dirs
|
||||||
dirs: Makefile
|
dirs: Makefile
|
||||||
@mkdir -p $(BIN)
|
@mkdir -p $(BIN)
|
||||||
|
@ -27,7 +29,9 @@ bridge: $(BIN)/guardiand
|
||||||
|
|
||||||
.PHONY: $(BIN)/guardiand
|
.PHONY: $(BIN)/guardiand
|
||||||
$(BIN)/guardiand: dirs generate
|
$(BIN)/guardiand: dirs generate
|
||||||
cd bridge && go build -mod=readonly -o ../$(BIN)/guardiand github.com/certusone/wormhole/bridge
|
cd bridge && go build -ldflags "-X github.com/certusone/wormhole/bridge/pkg/version.version=${VERSION}" \
|
||||||
|
-mod=readonly -o ../$(BIN)/guardiand \
|
||||||
|
github.com/certusone/wormhole/bridge
|
||||||
|
|
||||||
.PHONY: agent
|
.PHONY: agent
|
||||||
agent: $(BIN)/guardiand-solana-agent
|
agent: $(BIN)/guardiand-solana-agent
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/certusone/wormhole/bridge/pkg/version"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -20,6 +21,15 @@ var rootCmd = &cobra.Command{
|
||||||
Short: "Wormhole bridge server",
|
Short: "Wormhole bridge server",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Top-level version subcommand
|
||||||
|
var versionCmd = &cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Short: "Display binary version information",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
fmt.Println(version.Version())
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||||
func Execute() {
|
func Execute() {
|
||||||
|
@ -37,6 +47,7 @@ func init() {
|
||||||
rootCmd.AddCommand(guardiand.KeygenCmd)
|
rootCmd.AddCommand(guardiand.KeygenCmd)
|
||||||
rootCmd.AddCommand(guardiand.AdminCmd)
|
rootCmd.AddCommand(guardiand.AdminCmd)
|
||||||
rootCmd.AddCommand(guardiand.TemplateCmd)
|
rootCmd.AddCommand(guardiand.TemplateCmd)
|
||||||
|
rootCmd.AddCommand(versionCmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// initConfig reads in config file and ENV variables if set.
|
// initConfig reads in config file and ENV variables if set.
|
||||||
|
|
|
@ -3,6 +3,7 @@ package p2p
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/certusone/wormhole/bridge/pkg/version"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -191,6 +192,7 @@ func Run(obsvC chan *gossipv1.SignedObservation,
|
||||||
NodeName: nodeName,
|
NodeName: nodeName,
|
||||||
Counter: ctr,
|
Counter: ctr,
|
||||||
Timestamp: time.Now().UnixNano(),
|
Timestamp: time.Now().UnixNano(),
|
||||||
|
Version: version.Version(),
|
||||||
}}}
|
}}}
|
||||||
|
|
||||||
b, err := proto.Marshal(&msg)
|
b, err := proto.Marshal(&msg)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
package version
|
||||||
|
|
||||||
|
// Wormhole release version injected by the compiler.
|
||||||
|
var version = "development"
|
||||||
|
|
||||||
|
func Version() string {
|
||||||
|
return version
|
||||||
|
}
|
|
@ -27,8 +27,10 @@ message Heartbeat {
|
||||||
}
|
}
|
||||||
repeated Network networks = 4;
|
repeated Network networks = 4;
|
||||||
|
|
||||||
|
// Human-readable representation of the current bridge node release.
|
||||||
|
string version = 5;
|
||||||
|
|
||||||
// TODO: include statement of gk public key?
|
// TODO: include statement of gk public key?
|
||||||
// TODO: software version/release
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A SignedObservation is a signed statement by a given guardian node
|
// A SignedObservation is a signed statement by a given guardian node
|
||||||
|
|
Loading…
Reference in New Issue