-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
66 lines (53 loc) · 2.29 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
GH_USER ?= agilebits
NAME = sm
HARDWARE = $(shell uname -m)
VERSION ?= 0.14.0
GOOS ?= darwin
build:
@$(MAKE) build/linux/$(NAME)-amd64
@$(MAKE) build/linux/$(NAME)-arm64
@$(MAKE) build/linux/$(NAME)-armhf
@$(MAKE) build/darwin/$(NAME)-amd64
@$(MAKE) build/darwin/$(NAME)-arm64
build/darwin/$(NAME)-amd64:
mkdir -p build/darwin
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/darwin/$(NAME)-amd64
build/darwin/$(NAME)-arm64:
mkdir -p build/darwin
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/darwin/$(NAME)-arm64
build/linux/$(NAME)-amd64:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-amd64
build/linux/$(NAME)-arm64:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-arm64
build/linux/$(NAME)-armhf:
mkdir -p build/linux
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=5 go build -a -asmflags=-trimpath=/src -gcflags=-trimpath=/src \
-ldflags "-s -w -X main.Version=$(VERSION)" \
-o build/linux/$(NAME)-armhf
deps:
go get -u github.com/progrium/gh-release/...
go get -u github.com/spf13/viper/...
create-release-artifacts: build
rm -rf release && mkdir release
tar -zcf release/$(NAME)_$(VERSION)_linux_amd64.tgz -C build/linux $(NAME)-amd64
tar -zcf release/$(NAME)_$(VERSION)_linux_arm64.tgz -C build/linux $(NAME)-arm64
tar -zcf release/$(NAME)_$(VERSION)_linux_armhf.tgz -C build/linux $(NAME)-armhf
tar -zcf release/$(NAME)_$(VERSION)_darwin_amd64.tgz -C build/darwin $(NAME)-amd64
tar -zcf release/$(NAME)_$(VERSION)_darwin_arm64.tgz -C build/darwin $(NAME)-arm64
release: create-release-artifacts
gh-release create $(GH_USER)/$(NAME) $(VERSION) $(shell git rev-parse --abbrev-ref HEAD)
clean:
rm -rf build/*
install:
install build/$(GOOS)/sm $(GOPATH)/bin/
.PHONY: build release deps clean install