cmd: set version in main

parent f9f7ac91
Pipeline #17901034 passed with stages
in 10 minutes and 39 seconds
......@@ -42,7 +42,7 @@ build_script:
go version
go env
go generate
go build -ldflags "-s -w -X gitlab.com/blockforge/blockforge/cmd.VERSION=$env:APPVEYOR_BUILD_VERSION -linkmode external -extldflags '-static'" 2>&1 | %{ "$_" }
go build -ldflags "-s -w -X main.VERSION=$env:APPVEYOR_BUILD_VERSION -linkmode external -extldflags '-static'" 2>&1 | %{ "$_" }
after_build:
- ps: |
......
......@@ -51,7 +51,7 @@ compile:
- TAG="devel-${CI_COMMIT_SHA:0:7}"
- CI_COMMIT_TAG="${CI_COMMIT_TAG#v}"
- VERSION="${CI_COMMIT_TAG:-$TAG}"
- go build -ldflags "-s -w -X gitlab.com/blockforge/blockforge/cmd.VERSION=$VERSION"
- go build -ldflags "-s -w -X main.VERSION=$VERSION"
- tar cjf blockforge-$VERSION-$GOHOSTOS-$GOARCH.tar.bz2 blockforge
- sha256sum blockforge-$VERSION-$GOHOSTOS-$GOARCH.tar.bz2
artifacts:
......
......@@ -16,12 +16,6 @@ import (
"gitlab.com/blockforge/blockforge/miner"
)
var VERSION = "devel"
func init() {
cmd.Version = VERSION
}
var (
debug bool
configPath string
......@@ -53,7 +47,8 @@ func init() {
cmd.PersistentFlags().StringVar(&configPath, "config", defaultPath, "config file path")
}
func Execute() error {
func Execute(version string) error {
cmd.Version = version
return cmd.Execute()
}
......
......@@ -85,7 +85,7 @@ var guiCmd = &cobra.Command{
view := webview.New(webview.Settings{
URL: "http://" + listener.Addr().String(),
Title: fmt.Sprintf("BlockForge %v", VERSION),
Title: fmt.Sprintf("BlockForge %v", cmd.Version),
Width: 1232,
Height: 700,
Resizable: true,
......
......@@ -12,14 +12,17 @@ import (
//go:generate packr
var DSN = ""
var (
VERSION = "devel"
DSN = ""
)
func main() {
raven.SetDSN(DSN)
cobra.MousetrapHelpText = ""
err, _ := raven.CapturePanicAndWait(func() {
err := cmd.Execute()
err := cmd.Execute(VERSION)
if err != nil {
log.Panic(err)
}
......
......@@ -24,7 +24,7 @@ func TestMiner(t *testing.T) {
},
}
miner, err := New(config)
miner, err := New(&config)
if err != nil {
t.Fatal(err)
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment