-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
64 lines (50 loc) · 1.61 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
58
59
60
61
62
63
64
NAME=gosaic
VERSION=$(shell cat version)
BUILD_TIME=$(shell date)
BUILD_USER=$(shell whoami)
BUILD_HASH=$(shell git rev-parse HEAD 2>/dev/null || echo "")
ARCH=amd64
OS=linux darwin
LDFLAGS=-ldflags "-X 'github.com/atongen/gosaic/environment.Version=$(VERSION)' \
-X 'github.com/atongen/gosaic/environment.BuildTime=$(BUILD_TIME)' \
-X 'github.com/atongen/gosaic/environment.BuildUser=$(BUILD_USER)' \
-X 'github.com/atongen/gosaic/environment.BuildHash=$(BUILD_HASH)'"
all: clean test build
clean:
go clean
@rm -f `which ${NAME}`
vet:
go vet `go list ./... | grep -v /vendor/`
test:
go test -cover `go list ./... | grep -v /vendor/`
build: test
go install ${LDFLAGS}
distclean:
@mkdir -p dist
rm -rf dist/*
dist: test distclean
for arch in ${ARCH}; do \
for os in ${OS}; do \
env GOOS=$${os} GOARCH=$${arch} go build -v ${LDFLAGS} -o dist/${NAME}-${VERSION}-$${os}-$${arch}; \
done; \
done
sign: dist
$(eval key := $(shell git config --get user.signingkey))
for file in dist/*; do \
gpg2 --armor --local-user ${key} --detach-sign $${file}; \
done
package: sign
for arch in ${ARCH}; do \
for os in ${OS}; do \
tar czf dist/${NAME}-${VERSION}-$${os}-$${arch}.tar.gz -C dist ${NAME}-${VERSION}-$${os}-$${arch} ${NAME}-${VERSION}-$${os}-$${arch}.asc; \
done; \
done; \
find dist/ -type f ! -name "*.tar.gz" -delete
tag:
scripts/tag.sh
upload:
if [ ! -z "\${GITHUB_TOKEN}" ]; then \
ghr -t "${GITHUB_TOKEN}" -u ${BUILD_USER} -r ${NAME} -replace ${VERSION} dist/; \
fi
release: tag package upload
.PHONY: all clean vet test build distclean dist sign package tag release