Permalink
Browse files

Use `-X` compile param to set version

  • Loading branch information...
xthexder committed Aug 26, 2015
1 parent d026b34 commit 461b2b752097ade1802a6989c674a17dbf4cbf67
Showing with 9 additions and 12 deletions.
  1. +8 −10 Makefile
  2. +1 −2 version.go
View
@@ -7,14 +7,15 @@ COMBINED_GOPATH=$(GODEP_PATH):$(ORIGINAL_PATH)
.PHONY: packages deb test linux darwin windows
-all: version deb linux darwin windows docker
+build:
+ GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version git-`git rev-parse --short HEAD`" -o toxiproxy ./cmd
+
+all: deb linux darwin windows
deb: $(DEB)
darwin: tmp/build/toxiproxy-darwin-amd64
linux: tmp/build/toxiproxy-linux-amd64
windows: tmp/build/toxiproxy-windows-amd64.exe
-
-build:
- GOPATH=$(COMBINED_GOPATH) go build -o toxiproxy ./cmd
+release: all docker
clean:
rm tmp/build/*
@@ -23,17 +24,14 @@ clean:
test:
GOMAXPROCS=4 GOPATH=$(COMBINED_GOPATH) go test -v -race ./...
-version:
- sed -i "s/Version = \"[^\"]*\"/Version = \"$(VERSION)\"/" version.go
-
tmp/build/toxiproxy-linux-amd64:
- GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -o $(@) ./cmd
+ GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version $(VERSION)" -o $(@) ./cmd
tmp/build/toxiproxy-darwin-amd64:
- GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -o $(@) ./cmd
+ GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version $(VERSION)" -o $(@) ./cmd
tmp/build/toxiproxy-windows-amd64.exe:
- GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -o $(@) ./cmd
+ GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version $(VERSION)" -o $(@) ./cmd
docker:
docker build --tag="shopify/toxiproxy:$(VERSION)" .
View
@@ -1,4 +1,3 @@
package toxiproxy
-//go:generate make version
-var Version = "1.2.1"
+var Version = "git"

0 comments on commit 461b2b7

Please sign in to comment.