Include go version into builds
This commit is contained in:
parent
a21ff40588
commit
8b1f234b91
7
Makefile
7
Makefile
@ -1,9 +1,10 @@
|
|||||||
TARGETS = darwin/amd64 darwin/386 linux/amd64 linux/386 windows/amd64 windows/386
|
TARGETS = darwin/amd64 darwin/386 linux/amd64 linux/386 windows/amd64 windows/386
|
||||||
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')
|
||||||
|
GO_VERSION = $(shell go version | awk {'print $$3'})
|
||||||
|
BINDATA_IGNORE = $(shell git ls-files -io --exclude-standard $< | sed 's/^/-ignore=/;s/[.]/[.]/g')
|
||||||
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//')"
|
||||||
DOCKER_LATEST_TAG = "sosedoff/pgweb:latest"
|
DOCKER_LATEST_TAG = "sosedoff/pgweb:latest"
|
||||||
BINDATA_IGNORE = $(shell git ls-files -io --exclude-standard $< | sed 's/^/-ignore=/;s/[.]/[.]/g')
|
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
@echo ""
|
@echo ""
|
||||||
@ -49,12 +50,12 @@ release: clean assets
|
|||||||
@echo "Building binaries..."
|
@echo "Building binaries..."
|
||||||
@gox \
|
@gox \
|
||||||
-osarch "$(TARGETS)" \
|
-osarch "$(TARGETS)" \
|
||||||
-ldflags "-X github.com/sosedoff/pgweb/pkg/command.GitCommit=$(GIT_COMMIT) -X github.com/sosedoff/pgweb/pkg/command.BuildTime=$(BUILD_TIME)" \
|
-ldflags "-X github.com/sosedoff/pgweb/pkg/command.GitCommit=$(GIT_COMMIT) -X github.com/sosedoff/pgweb/pkg/command.BuildTime=$(BUILD_TIME) -X github.com/sosedoff/pgweb/pkg/command.GoVersion=$(GO_VERSION)" \
|
||||||
-output "./bin/pgweb_{{.OS}}_{{.Arch}}"
|
-output "./bin/pgweb_{{.OS}}_{{.Arch}}"
|
||||||
|
|
||||||
@echo "Building ARM binaries..."
|
@echo "Building ARM binaries..."
|
||||||
GOOS=linux GOARCH=arm GOARM=5 go build \
|
GOOS=linux GOARCH=arm GOARM=5 go build \
|
||||||
-ldflags "-X github.com/sosedoff/pgweb/pkg/command.GitCommit=$(GIT_COMMIT) -X github.com/sosedoff/pgweb/pkg/command.BuildTime=$(BUILD_TIME)" \
|
-ldflags "-X github.com/sosedoff/pgweb/pkg/command.GitCommit=$(GIT_COMMIT) -X github.com/sosedoff/pgweb/pkg/command.BuildTime=$(BUILD_TIME) -X github.com/sosedoff/pgweb/pkg/command.GoVersion=$(GO_VERSION)" \
|
||||||
-o "./bin/pgweb_linux_arm_v5"
|
-o "./bin/pgweb_linux_arm_v5"
|
||||||
|
|
||||||
@echo "\nPackaging binaries...\n"
|
@echo "\nPackaging binaries...\n"
|
||||||
|
@ -143,12 +143,14 @@ func initOptions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printVersion() {
|
func printVersion() {
|
||||||
str := fmt.Sprintf("Pgweb v%s", command.Version)
|
chunks := []string{fmt.Sprintf("Pgweb v%s", command.Version)}
|
||||||
if command.GitCommit != "" {
|
if command.GitCommit != "" {
|
||||||
str += fmt.Sprintf(" (git: %s)", command.GitCommit)
|
chunks = append(chunks, fmt.Sprintf("(git: %s)", command.GitCommit))
|
||||||
}
|
}
|
||||||
|
if command.GoVersion != "" {
|
||||||
fmt.Println(str)
|
chunks = append(chunks, fmt.Sprintf("(go: %s)", command.GoVersion))
|
||||||
|
}
|
||||||
|
fmt.Println(strings.Join(chunks, " "))
|
||||||
}
|
}
|
||||||
|
|
||||||
func startServer() {
|
func startServer() {
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// Version is the current Pgweb application version
|
||||||
Version = "0.11.4"
|
Version = "0.11.4"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
// GitCommit contains the Git commit SHA for the binary
|
||||||
GitCommit string
|
GitCommit string
|
||||||
|
|
||||||
|
// BuildTime contains the binary build time
|
||||||
BuildTime string
|
BuildTime string
|
||||||
|
|
||||||
|
// GoVersion contains the Go runtime version
|
||||||
|
GoVersion string
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user