forked from webdevops/go-replace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (42 loc) · 1.36 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
SOURCE = $(wildcard *.go)
TAG ?= $(shell git describe --tags)
GOBUILD = go build -ldflags '-w'
ALL = \
$(foreach arch,64 32,\
$(foreach suffix,linux osx win.exe,\
build/gr-$(arch)-$(suffix))) \
$(foreach arch,arm arm64,\
build/gr-$(arch)-linux)
all: test build
build: clean test $(ALL)
# cram is a python app, so 'easy_install/pip install cram' to run tests
test:
cram tests/*.test
clean:
rm -f $(ALL)
# os is determined as thus: if variable of suffix exists, it's taken, if not, then
# suffix itself is taken
win.exe = windows
osx = darwin
build/gr-64-%: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=amd64 $(GOBUILD) -o $@
build/gr-32-%: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=$(firstword $($*) $*) GOARCH=386 $(GOBUILD) -o $@
build/gr-arm-linux: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=6 $(GOBUILD) -o $@
build/gr-arm64-linux: $(SOURCE)
@mkdir -p $(@D)
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 $(GOBUILD) -o $@
release: build
github-release release -u webdevops -r go-replace -t "$(TAG)" -n "$(TAG)" --description "$(TAG)"
@for x in $(ALL); do \
echo "Uploading $$x" && \
github-release upload -u webdevops \
-r go-replace \
-t $(TAG) \
-f "$$x" \
-n "$$(basename $$x)"; \
done