use build info
This commit is contained in:
parent
a1c017545b
commit
c08f283f80
|
@ -12,9 +12,9 @@ import (
|
||||||
var buildUsage = `
|
var buildUsage = `
|
||||||
warren build - Runs go build and populates the following variables:
|
warren build - Runs go build and populates the following variables:
|
||||||
|
|
||||||
Build.GitBranch from git
|
BuildGitBranch from git
|
||||||
Build.GitHash from git
|
BuildGitHash from git
|
||||||
Build.Date from system time
|
BuildDate from system time
|
||||||
`
|
`
|
||||||
|
|
||||||
var buildCmd = &Command{
|
var buildCmd = &Command{
|
||||||
|
@ -32,7 +32,7 @@ func buildRun(cmd *Command, args ...string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
date := time.Now().Format(time.RFC3339)
|
date := time.Now().Format(time.RFC3339)
|
||||||
gobuild := exec.Command("go", "build", "-ldflags", fmt.Sprintf("-X main.Build.Date %s -X main.Build.GitHash %s -X main.Build.GitBranch %s\"", date, warren.GitHash(), warren.GitBranch()))
|
gobuild := exec.Command("go", "build", "-ldflags", fmt.Sprintf("-X main.BuildDate %s -X main.BuildGitHash %s -X main.BuildGitBranch %s", date, warren.GitHash(), warren.GitBranch()))
|
||||||
gobuild.Stderr = os.Stderr
|
gobuild.Stderr = os.Stderr
|
||||||
gobuild.Stdout = os.Stdout
|
gobuild.Stdout = os.Stdout
|
||||||
err := gobuild.Run()
|
err := gobuild.Run()
|
||||||
|
|
12
warren.go
12
warren.go
|
@ -8,13 +8,9 @@ import (
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BuildInfo struct {
|
var BuildGitHash string
|
||||||
GitHash string
|
var BuildGitBranch string
|
||||||
GitBranch string
|
var BuildDate string
|
||||||
Date string
|
|
||||||
}
|
|
||||||
|
|
||||||
var Build BuildInfo
|
|
||||||
|
|
||||||
var usagePrefix = `
|
var usagePrefix = `
|
||||||
warren is a tool for building, deploying and running multiple versions of a Go server
|
warren is a tool for building, deploying and running multiple versions of a Go server
|
||||||
|
@ -34,7 +30,7 @@ var commands = []*Command{
|
||||||
}
|
}
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Println(Build.GitBranch, " ", Build.GitHash, " ", Build.Date)
|
fmt.Println(BuildGitBranch, " ", BuildGitHash, " ", BuildDate)
|
||||||
fmt.Print(usagePrefix)
|
fmt.Print(usagePrefix)
|
||||||
usageTmpl.Execute(os.Stdout, commands)
|
usageTmpl.Execute(os.Stdout, commands)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue