-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (25 loc) · 899 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
EXE := health-check
VER := $(shell git describe --tags)
PATH := build:$(PATH)
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
.PHONY: darwin linux windows release clean dist-clean test
$(EXE): go.mod *.go
go build -v -ldflags '-s -w -X main.Version=$(VER)' -o $@
release: $(EXE) darwin windows linux
darwin linux:
GOOS=$@ go build -ldflags '-s -w -X main.Version=$(VER)' -o $(EXE)-$(VER)-$@-$(GOARCH)
upx -v $(EXE)-$(VER)-$@-$(GOARCH)
# $(shell go env GOEXE) is evaluated in the context of the Makefile host (before GOOS is evaluated), so hard-code .exe
windows:
GOOS=$@ go build -ldflags '-s -w -X main.Version=$(VER)' -o $(EXE)-$(VER)-$@-$(GOARCH).exe
upx -v $(EXE)-$(VER)-$@-$(GOARCH).exe
clean:
rm -f $(EXE) $(EXE)-*-*-*
dist-clean: clean
rm -f go.sum
docker: clean linux Dockerfile
docker build . -t $(EXE):$(VER)
test: $(EXE)
mv $(EXE) build
go test -v ./...