-
Notifications
You must be signed in to change notification settings - Fork 24
/
Makefile
96 lines (83 loc) · 2.53 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
# Go makefile
#export env
#basic information
ProjectAdmin := "cronyadmin"
ProjectNode := "cronynode"
PROJECTBASE := $(shell pwd)
PROJECTBIN := $(PROJECTBASE)/bin
AdminConf := "$(PROJECTBIN)/admin"
NodeConf := "$(PROJECTBIN)/node"
TIMESTAMP := $(shell /bin/date "+%F %T")
#change to deploy environment
AdminFile := ./admin/cmd/main.go
NodeFile := ./node/cmd/main.go
WebFile := ./admin/web
#compile ldflags
LDFLAGS := -s -w \
-X 'main.BuildGitBranch=$(shell git describe --all)' \
-X 'main.BuildGitRev=$(shell git rev-list --count HEAD)' \
-X 'main.BuildGitCommit=$(shell git rev-parse HEAD)' \
-X 'main.BuildDate=$(shell /bin/date "+%F %T")'
linux-dev: clean install-web build-web
@echo "install linux amd64 dev version"
@if [ ! -d $(AdminConf)/logs ]; then \
mkdir -p $(AdminConf)/logs; \
fi
@if [ ! -d $(NodeConf)/logs ]; then \
mkdir -p $(NodeConf)/logs; \
fi
@cp -r ./admin/conf $(AdminConf)
@cp -r ./node/conf $(NodeConf)
@echo "building project cronyadmin..."
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $(PROJECTBIN)/$(ProjectAdmin) $(AdminFile)
@echo "building project cronynode..."
@CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o $(PROJECTBIN)/$(ProjectNode) $(NodeFile)
@chmod +x $(PROJECTBIN)/$(ProjectAdmin)
@chmod +x $(PROJECTBIN)/$(ProjectNode)
@mv $(WebFile)/dist bin/
@echo "build success."
install-web:
@echo "install web node_modules..."
cd $(WebFile)&&npm install
build-web:
@echo "building web..."
cd $(WebFile)&&yarn build
run-web:
@echo "running web..."
cd $(WebFile) &&yarn serve
local-dev: clean install-web
@echo "install local dev version"
@go mod tidy
@if [ ! -d $(NodeConf)/logs ]; then \
mkdir -p $(NodeConf)/logs; \
fi
@if [ ! -d $(AdminConf)/logs ]; then \
mkdir -p $(AdminConf)/logs; \
fi
@cp -r ./admin/conf $(AdminConf)
@cp -r ./node/conf $(NodeConf)
@echo "building project cronyadmin..."
@CGO_ENABLED=0 go build -v -o $(PROJECTBIN)/$(ProjectAdmin) $(AdminFile)
@echo "building project cronynode..."
@CGO_ENABLED=0 go build -v -o $(PROJECTBIN)/$(ProjectNode) $(NodeFile)
@chmod +x $(PROJECTBIN)/$(PROJECTNAME)
@chmod +x $(PROJECTBIN)/$(ProjectNode)
@echo "build success."
gitpush: clean fmt
git add .
git commit -m "$(m) changed at $(TIMESTAMP)"
git push
fmt:
@go fmt $(PROJECTBASE)/...
@echo "hello"
@go mod tidy
clean:
@#echo $(PROJECTBIN)
@rm -rf $(PROJECTBIN)/* &>/dev/null
depend:
go mod download
gitpull: fmt
git add .
git commit -m "$(m) changed at $(TIMESTAMP)"
git pull
.PHONY: fmt clean git