Optimized version management

Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
Jianhui Zhao
2019-04-27 23:23:55 +08:00
parent 23c0cfc54d
commit ca7dcda857
4 changed files with 32 additions and 16 deletions
+5 -1
View File
@@ -1,5 +1,9 @@
#!/bin/sh
VersionPath="github.com/zhaojh329/rttys/version"
GitCommit=$(git log --pretty=format:"%h" -1)
BuildTime=$(date +%FT%T%z)
generate() {
local os="$1"
local arch="$2"
@@ -14,7 +18,7 @@ generate() {
bin="rttys.exe"
}
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags='-s -w' -o output/$dir/$bin
GOOS=$os GOARCH=$arch CGO_ENABLED=0 go build -ldflags="-s -w -X $VersionPath.gitCommit=$GitCommit -X $VersionPath.buildTime=$BuildTime" -o output/$dir/$bin
cd output
+7 -2
View File
@@ -33,6 +33,7 @@ import (
"time"
"github.com/kylelemons/go-gypsy/yaml"
"github.com/zhaojh329/rttys/version"
"github.com/howeyc/gopass"
"github.com/rifflock/lfshook"
@@ -63,8 +64,12 @@ func main() {
os.Exit(1)
}
log.Infof("go version: %s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
log.Info("rttys version:", rttys_version())
log.Info("Go Version: ", runtime.Version())
log.Info("Go OS/Arch: ", runtime.GOOS, "/", runtime.GOARCH)
log.Info("Rttys Version: ", version.Version())
log.Info("Git Commit: ", version.GitCommit())
log.Info("Build Time: ", version.BuildTime())
br := newBroker()
go br.run()
-13
View File
@@ -1,13 +0,0 @@
package main
import "fmt"
const (
RTTYS_VERSION_MAJOR = 2
RTTYS_VERSION_MINOR = 10
RTTYS_VERSION_PATCH = 0
)
func rttys_version() string {
return fmt.Sprintf("%d.%d.%d", RTTYS_VERSION_MAJOR, RTTYS_VERSION_MINOR, RTTYS_VERSION_PATCH)
}
+20
View File
@@ -0,0 +1,20 @@
package version
const version = "2.10.0"
var (
gitCommit = ""
buildTime = ""
)
func Version() string {
return version
}
func GitCommit() string {
return gitCommit
}
func BuildTime() string {
return buildTime
}