mirror of
https://github.com/zhaojh329/rttys.git
synced 2026-02-27 09:53:21 +08:00
Optimized version management
Signed-off-by: Jianhui Zhao <jianhuizhao329@gmail.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
@@ -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)
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user