Include build arch info into binary
This commit is contained in:
parent
f48cc5f007
commit
829658ae4d
2
Makefile
2
Makefile
@ -1,6 +1,7 @@
|
|||||||
PKG = github.com/sosedoff/pgweb
|
PKG = github.com/sosedoff/pgweb
|
||||||
GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
GIT_COMMIT ?= $(shell git rev-parse HEAD)
|
||||||
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')
|
BUILD_TIME ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ" | tr -d '\n')
|
||||||
|
BUILD_ARCH ?= $(shell uname -s | awk '{print tolower($0)}')/$(shell uname -m)
|
||||||
GO_VERSION ?= $(shell go version | awk {'print $$3'})
|
GO_VERSION ?= $(shell go version | awk {'print $$3'})
|
||||||
|
|
||||||
DOCKER_RELEASE_TAG = "sosedoff/pgweb:$(shell git describe --abbrev=0 --tags | sed 's/v//')"
|
DOCKER_RELEASE_TAG = "sosedoff/pgweb:$(shell git describe --abbrev=0 --tags | sed 's/v//')"
|
||||||
@ -9,6 +10,7 @@ DOCKER_LATEST_TAG = "sosedoff/pgweb:latest"
|
|||||||
LDFLAGS = -s -w
|
LDFLAGS = -s -w
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT)
|
LDFLAGS += -X $(PKG)/pkg/command.GitCommit=$(GIT_COMMIT)
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME)
|
LDFLAGS += -X $(PKG)/pkg/command.BuildTime=$(BUILD_TIME)
|
||||||
|
LDFLAGS += -X $(PKG)/pkg/command.BuildArch=$(BUILD_ARCH)
|
||||||
LDFLAGS += -X $(PKG)/pkg/command.GoVersion=$(GO_VERSION)
|
LDFLAGS += -X $(PKG)/pkg/command.GoVersion=$(GO_VERSION)
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
|
@ -17,6 +17,9 @@ var (
|
|||||||
// BuildTime contains the binary build time
|
// BuildTime contains the binary build time
|
||||||
BuildTime string
|
BuildTime string
|
||||||
|
|
||||||
|
// BuildArch contains the OS architecture of the binary
|
||||||
|
BuildArch string
|
||||||
|
|
||||||
// GoVersion contains the build time Go version
|
// GoVersion contains the build time Go version
|
||||||
GoVersion string
|
GoVersion string
|
||||||
|
|
||||||
@ -29,12 +32,14 @@ type VersionInfo struct {
|
|||||||
GitCommit string `json:"git_sha"`
|
GitCommit string `json:"git_sha"`
|
||||||
BuildTime string `json:"build_time"`
|
BuildTime string `json:"build_time"`
|
||||||
GoVersion string `json:"go_version"`
|
GoVersion string `json:"go_version"`
|
||||||
|
BuildArch string `json:"build_arch"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
Info.Version = Version
|
Info.Version = Version
|
||||||
Info.GitCommit = GitCommit
|
Info.GitCommit = GitCommit
|
||||||
Info.BuildTime = BuildTime
|
Info.BuildTime = BuildTime
|
||||||
|
Info.BuildArch = BuildArch
|
||||||
Info.GoVersion = GoVersion
|
Info.GoVersion = GoVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +55,9 @@ func VersionString() string {
|
|||||||
if BuildTime != "" {
|
if BuildTime != "" {
|
||||||
chunks = append(chunks, fmt.Sprintf("(build time: %s)", BuildTime))
|
chunks = append(chunks, fmt.Sprintf("(build time: %s)", BuildTime))
|
||||||
}
|
}
|
||||||
|
if BuildArch != "" {
|
||||||
|
chunks = append(chunks, fmt.Sprintf("(arch: %s)", BuildArch))
|
||||||
|
}
|
||||||
|
|
||||||
return strings.Join(chunks, " ")
|
return strings.Join(chunks, " ")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user