-
Notifications
You must be signed in to change notification settings - Fork 39
/
Makefile
43 lines (33 loc) · 864 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
35
36
37
38
39
40
41
42
43
NAME=harx
VERSION=$$(git describe --tags --always)
SHORT_VERSION=$$(git describe --tags --always | awk -F '-' '{print $$1}')
LDFLAGS=-ldflags=all="-X main.version=${SHORT_VERSION}"
all: tools build
tools:
GO111MODULE=off go get -u -v "github.com/mitchellh/gox"
build:
@mkdir -p bin/
go get -t ./...
go test -v ./...
go build ${LDFLAGS} -o bin/${NAME} ./cmd/harx/main.go
xbuild: clean
@mkdir -p build
gox \
-os="linux" \
-os="windows" \
-os="darwin" \
-arch="amd64" \
${LDFLAGS} \
-output="build/{{.Dir}}_$(VERSION)_{{.OS}}_{{.Arch}}/$(NAME)" \
./...
package: xbuild
$(eval FILES := $(shell ls build))
@mkdir -p build/tgz
for f in $(FILES); do \
(cd $(shell pwd)/build && tar -zcvf tgz/$$f.tar.gz $$f); \
echo $$f; \
done
clean:
@rm -rf bin/ && rm -rf build/
ci: tools package
.PHONY: all tools build xbuild package clean ci