-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
106 lines (84 loc) · 1.83 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
99
100
101
102
103
104
105
106
# Go parameters
NAME=lsti
VERSION=1.0.2
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
DIST_DIR=dist
## Show help
help: setup-help
@make2help $(MAKEFILE_LIST)
.PHONY: help
# Setup
## Set up dev tools
setup: setup-help setup-goxz setup-ghr
.PHONY: setup
## Set up goxz
setup-goxz:
$(GOGET) github.com/Songmu/goxz/cmd/goxz
.PHONY: setup-goxz
## Set up ghr
setup-ghr:
$(GOGET) github.com/tcnksm/ghr
.PHONY: setup-ghr
## Set up make2help
setup-help:
$(GOGET) github.com/Songmu/make2help/cmd/make2help
.PHONY: setup-help
## Install dependencies
deps:
$(GOGET) github.com/jessevdk/go-flags
$(GOGET) github.com/jmespath/go-jmespath
$(GOGET) github.com/mattn/go-zglob
$(GOGET) github.com/olekukonko/tablewriter
$(GOGET) github.com/russross/blackfriday
.PHONY: deps
# Run
## Run tests and build binary
all: test build
.PHONY: all
## Build binary
build:
$(GOBUILD) -v
.PHONY: build
## Run tests
test:
$(GOTEST) -v ./...
.PHONY: test
## Remove binaries
clean:
$(GOCLEAN)
rm -rf $(DIST_DIR)
.PHONY: clean
## Builds the binary and executes the application consequently
run:
$(GOBUILD) -v ./...
./$(NAME)
.PHONY: run
# Cross compilation
## Build binary for windows-amd64
build-windows-amd64:
GOOS=windows GOARCH=amd64 $(GOBUILD) -v
## Build binary for windows-386
build-windows-386:
GOOS=windows GOARCH=386 $(GOBUILD) -v
## Build binary for linux-amd64
build-linux-amd64:
GOOS=linux GOARCH=amd64 $(GOBUILD) -v
## Build binary for linux-386
build-linux-386:
GOOS=linux GOARCH=386 $(GOBUILD) -v
# Release
## Package binaries
package: deps setup-goxz
goxz -pv=$(VERSION) -os=windows,darwin,linux -arch=amd64,386 -d=$(DIST_DIR)
.PHONY: package
## Release binaries with ghr
ghr:
ghr $(VERSION) $(DIST_DIR)
.PHONY: ghr
## Crossbuild and release packages
release: clean package ghr
.PHONY: release