-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
98 lines (81 loc) · 2.14 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
NAME = pack-repo
DIST_DIRS = find * -type d -exec
# go option
GO ?= go
TAGS := kqueue
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
BINDIR := $(CURDIR)/bin
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/draftcreate/draft-pack-repo/cmd/...
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/draftcreate/draft-pack-repo/cmd/$(NAME)
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf $(NAME)-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r $(NAME)-${VERSION}-{}.zip {} \; \
)
.PHONY: checksum
checksum:
for f in _dist/*.{gz,zip} ; do \
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
done
.PHONY: compress-binary
compress-binary: BINDIR = ./rootfs/bin
compress-binary:
@if [ -z $$(which upx) ]; then \
echo "Missing \`upx\` tool to compress binaries"; \
else \
upx --quiet ${BINDIR}/${NAME}; \
fi
.PHONY: clean
clean:
-rm bin/*
-rm -rf _dist/
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint test-cover
test-cover:
scripts/cover.sh
.PHONY: test-lint
test-lint:
scripts/lint.sh
.PHONY: test-unit
test-unit:
$(GO) test $(GOFLAGS) -cover -run $(TESTFLAGS) ./cmd/... ./version/...
HAS_GOMETALINTER := $(shell command -v gometalinter;)
HAS_DEP := $(shell command -v dep;)
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install git)
endif
dep ensure
include versioning.mk
# Set VERSION to build release assets for a specific version
.PHONY: release-assets
release-assets: build-cross dist checksum