Version management (#141)

* Provide a better version management approach

* Fix typo
This commit is contained in:
陈键冬 2020-05-11 20:23:53 +08:00 committed by GitHub
parent b1c1fda547
commit 9264aa6293
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 21 deletions

View File

@ -1,5 +1,8 @@
#!/bin/bash
# release version
version=1.3.3
CWD=$(cd $(dirname $0)/; pwd)
cd $CWD
@ -136,13 +139,13 @@ status()
build_one()
{
mod=$1
go build -mod=vendor -o n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go
go build -ldflags "-X main.version=${version} -X main.buildTime=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.gitHash=`git rev-parse HEAD`" -mod=vendor -o n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go
}
build_docker()
{
mod=$1
go build -mod=vendor -o bin/n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go
go build -ldflags "-X main.version=${version} -X main.buildTime=`date -u '+%Y-%m-%d_%I:%M:%S%p'` -X main.gitHash=`git rev-parse HEAD`" -mod=vendor -o bin/n9e-${mod} --tags "md5" src/modules/${mod}/${mod}.go
}
build()

View File

@ -28,15 +28,14 @@ import (
"github.com/toolkits/pkg/runner"
)
// changelog:
// 1: init project
// 2: mount ignore refactor
const version = 2
var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -46,7 +45,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}

View File

@ -23,12 +23,14 @@ import (
"github.com/toolkits/pkg/runner"
)
const version = 1
var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -38,7 +40,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}

View File

@ -27,12 +27,14 @@ import (
"github.com/didi/nightingale/src/toolkits/stats"
)
const version = 1
var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -42,7 +44,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}

View File

@ -28,6 +28,10 @@ var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -37,7 +41,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", config.Version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}

View File

@ -22,12 +22,14 @@ import (
"github.com/toolkits/pkg/runner"
)
const version = 1
var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -37,7 +39,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}

View File

@ -23,12 +23,14 @@ import (
"github.com/toolkits/pkg/runner"
)
const version = 1
var (
vers *bool
help *bool
conf *string
version = "No Version Provided"
gitHash = "No GitHash Provided"
buildTime = "No BuildTime Provided"
)
func init() {
@ -38,7 +40,9 @@ func init() {
flag.Parse()
if *vers {
fmt.Println("version:", version)
fmt.Println("Version:", version)
fmt.Println("Git Commit Hash:", gitHash)
fmt.Println("UTC Build Time:", buildTime)
os.Exit(0)
}