-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
55 lines (46 loc) · 1.61 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
Branch=$(shell git symbolic-ref --short -q HEAD)
Commit=$(shell git rev-parse --short HEAD)
Date=$(shell git log --pretty=format:%cd $(Commit) -1)
Author=$(shell git log --pretty=format:%an $(Commit) -1)
shortDate=$(shell git log -1 --format="%at" | xargs -I{} date -d @{} +%Y%m%d)
Email=$(shell git log --pretty=format:%ae $(Commit) -1)
Ver=$(shell echo $(Branch)-$(Commit)-$(shortDate))
GoVersion=$(shell go version )
.PHONY: statik
statik:
go install github.com/rakyll/statik@latest
statik -f -src=web
.PHONY: compile
compile: statik
GOOS=linux go build -a -installsuffix cgo \
-ldflags "-X 'github.com/Ankr-network/uscan/cmd.Branch=$(Branch)' \
-X 'github.com/Ankr-network/uscan/cmd.Commit=$(Commit)' \
-X 'github.com/Ankr-network/uscan/cmd.Date=$(Date)' \
-X 'github.com/Ankr-network/uscan/cmd.Author=$(Author)' \
-X 'github.com/Ankr-network/uscan/cmd.Email=$(Email)' \
-X 'github.com/Ankr-network/uscan/cmd.GoVersion=$(GoVersion)'" -o bin/uscan
.PHONY: perf
perf: compile
bin/uscan --config .uscan.yaml
.PHONY: race
race:
go run -race main.go --config .uscan.yaml
.PHONY: start
start: compile
bin/uscan --config .uscan.yaml
.PHONY: build
build:
docker build \
--build-arg GoVersion='$(GoVersion)' \
--build-arg Branch='$(Branch)' \
--build-arg Commit='$(Commit)' \
--build-arg Date='$(Date)' \
--build-arg Author='$(Author)' \
--build-arg Email='$(Email)' \
-t ankrnetwork/uscan:$(Ver) .
docker image prune -f --filter label=stage=builder
.PHONY: release
release: build
docker push ankrnetwork/uscan:$(Ver)
docker tag ankrnetwork/uscan:$(Ver) ankrnetwork/uscan:latest
docker push ankrnetwork/uscan:latest