forked from mattolenik/hclq
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
57 lines (44 loc) · 1.67 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Version and linker flags
VERSION=$(shell echo $$(ver=$$(git tag -l --points-at HEAD) && [ -z $$ver ] && ver=$$(git describe --always --dirty); printf $$ver))
LDFLAGS=-s -w -X github.com/mattolenik/hclq/cmd.version=${VERSION}
GOOS=darwin linux windows
GOARCH=amd64
# Dependency vars
UPX_URL=$(shell curl -sL https://api.github.com/repos/upx/upx/releases/latest | grep -e "browser_download_url.*amd64_linux" | awk -F'"' '{print $$4}')
default: test build
build:
go build -i -ldflags="${LDFLAGS}" -gcflags='-N -l' -o dist/hclq
cideps:
# Download and extract UPX
[ -n "$$CI" ] && curl -sSL ${UPX_URL} | tar xJ --wildcards --strip-components=1 "*/upx"
clean:
rm -rf dist/ vendor/
dist: get
set -v; for goos in ${GOOS}; do GOOS=$$goos GOARCH=${GOARCH} go build -i -ldflags="${LDFLAGS}" -o dist/hclq-$$goos-${GOARCH}; done
# Remove binary used for testing
rm dist/hclq
[ -n "$$CI" ] && ./upx dist/* || upx dist/*
get:
go get -u github.com/golang/dep/cmd/dep
$$GOPATH/bin/dep ensure
# GitHub release tool
go get -u github.com/tcnksm/ghr
install: get
go install -ldflags="${LDFLAGS}"
brew:
./mo homebrew/hclq.rb.mo > homebrew/hclq.rb
publish: cideps test dist brew
( \
VERSION=${VERSION}; \
LINUX_FILENAME="hclq-linux-amd64"; \
DARWIN_FILENAME="hclq-darwin-amd64"; \
LINUX_HASH=$$(shasum -a 256 dist/$$LINUX_FILENAME | awk '{print $$1}'); \
DARWIN_HASH=$$(shasum -a 256 dist/$$DARWIN_FILENAME | awk '{print $$1}'); \
shasum -a 256 dist/* > dist/hclq-shasums; \
if [ -n "$$TRAVIS_TAG" ]; then \
ghr -u "$$GITHUB_USER" ${VERSION} dist/; \
fi; \
)
test: get build
HCLQ_BIN=$$(pwd)/dist/hclq go test -v "./..."
.PHONY: brew get dist cideps publish build install test clean