From 59e314b033f7c477a6fce7a3738339fcd0eaba7a Mon Sep 17 00:00:00 2001 From: Alexei Ledenev Date: Wed, 28 Apr 2021 11:24:09 +0300 Subject: [PATCH] prepare for homebrew formula build --- Makefile | 13 ++++++++++--- cmd/main.go | 12 +++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index e9d471c..9b899c1 100644 --- a/Makefile +++ b/Makefile @@ -29,7 +29,14 @@ export CGO_ENABLED=0 export GOPROXY=https://proxy.golang.org .PHONY: all -all: update-data update_price fmt lint test-verbose ; $(info $(M) building $(TARGETOS)/$(TARGETARCH) binary...) @ ## Build program binary +all: update-data update-price fmt lint test-verbose ; $(info $(M) building $(TARGETOS)/$(TARGETARCH) binary...) @ ## Build program binary + $Q env GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) $(GO) build \ + -tags release \ + -ldflags "$(LDFLAGS_VERSION)" \ + -o $(BIN)/$(basename $(MODULE)) ./cmd/main.go + +.PHONY: build +build: update-data update-price ; $(info $(M) building $(TARGETOS)/$(TARGETARCH) binary...) @ ## Build program binary $Q env GOOS=$(TARGETOS) GOARCH=$(TARGETARCH) $(GO) build \ -tags release \ -ldflags "$(LDFLAGS_VERSION)" \ @@ -98,8 +105,8 @@ update-data: check-deps; @ ## Update Spot Advisor data file @wget -nv $(SPOT_ADVISOR_DATA_URL) -O - > public/spot/data/spot-advisor-data.json @echo "spot advisor data updated" -.PHONY: update_price -update_price: check-deps; @ ## Update Spot pricing data file +.PHONY: update-price +update-price: check-deps; @ ## Update Spot pricing data file @mkdir -p public/spot/data @wget -nv $(SPOT_PRICE_DATA_URL) -O - > public/spot/data/spot-price-data.json @sed -i'' -e "s/callback(//g" public/spot/data/spot-price-data.json diff --git a/cmd/main.go b/cmd/main.go index 1357092..dbc3395 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -236,9 +236,15 @@ func main() { } cli.VersionPrinter = func(c *cli.Context) { fmt.Printf("spotinfo %s\n", Version) - fmt.Printf(" Build date: %s\n", BuildDate) - fmt.Printf(" Git commit: %s\n", GitCommit) - fmt.Printf(" Git branch: %s\n", GitBranch) + if BuildDate != "" && BuildDate != "unknown" { + fmt.Printf(" Build date: %s\n", BuildDate) + } + if GitCommit != "" { + fmt.Printf(" Git commit: %s\n", GitCommit) + } + if GitBranch != "" { + fmt.Printf(" Git branch: %s\n", GitBranch) + } fmt.Printf(" Built with: %s\n", runtime.Version()) }