-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
37 lines (31 loc) · 1.16 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
VERSION=0.2.0
V=github.com/buchanae/cwl/version
VERSION_LDFLAGS=\
-X "$(V).BuildDate=$(shell date)" \
-X "$(V).GitCommit=$(shell git rev-parse --short HEAD)" \
-X "$(V).GitBranch=$(shell git symbolic-ref -q --short HEAD)" \
-X "$(V).GitUpstream=$(shell git remote get-url $(shell git config branch.$(shell git symbolic-ref -q --short HEAD).remote) 2> /dev/null)" \
-X "$(V).Version=$(VERSION)"
install:
@go install -ldflags '$(VERSION_LDFLAGS)' github.com/buchanae/cwl/cmd/cwl
build-release: clean-release cross-compile
if [ $$(git rev-parse --abbrev-ref HEAD) != 'master' ]; then \
echo 'This command should only be run from master'; \
exit 1; \
fi
for f in $$(ls -1 build/bin); do \
mkdir -p build/release/$$f-$(VERSION); \
cp build/bin/$$f build/release/$$f-$(VERSION)/cwl; \
tar -C build/release/$$f-$(VERSION) -czf build/release/$$f-$(VERSION).tar.gz .; \
done
cross-compile:
@echo '=== Cross compiling... ==='
@for GOOS in darwin linux; do \
for GOARCH in amd64; do \
GOOS=$$GOOS GOARCH=$$GOARCH go build -a \
-ldflags '$(VERSION_LDFLAGS)' \
-o build/bin/cwl-$$GOOS-$$GOARCH ./cmd/cwl; \
done; \
done
clean-release:
rm -rf ./build/release