-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (46 loc) · 2.05 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
BUILD_VERSION ?= $(shell cat version || echo "0.0.1")
BUILD_DATE := $(shell date "+%F %T")
COMMIT_SHA1 := $(shell git rev-parse HEAD || echo "a1.b2.c3")
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {sub("\\\\n",sprintf("\n%22c"," "), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
fmt:
@echo gofmt -l
@OUTPUT=`gofmt -l . 2>&1`; \
if [ "$$OUTPUT" ]; then \
echo "gofmt must be run on the following files:"; \
echo "$$OUTPUT"; \
exit 1; \
fi
default: fmt ## fmt code
build: clean ## 构建二进制
@echo "build bin ${BUILD_VERSION} ${BUILD_DATE} ${COMMIT_SHA1}"
#@bash hack/docker/build.sh ${version} ${tagversion} ${commit_sha1}
# go get github.com/mitchellh/gox
@gox -osarch="darwin/amd64 linux/amd64 windows/amd64" \
-output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" \
-ldflags "-X 'github.com/ysicing/kc/cmd.Version=${BUILD_VERSION}' \
-X 'github.com/ysicing/kc/cmd.BuildDate=${BUILD_DATE}' \
-X 'github.com/ysicing/kc/cmd.CommitID=${COMMIT_SHA1}'"
docker: build ## 构建镜像
@echo "build docker images ${BUILD_VERSION}"
@docker build -t ysicing/kc .
@docker build -t ysicing/kc:${BUILD_VERSION} .
dpush: docker
@docker push ysicing/kc
@docker push ysicing/kc:${BUILD_VERSION}
release: ## github release
ghr -u ysicing -t $(GITHUB_RELEASE_TOKEN) -replace -recreate --debug ${BUILD_VERSION} -n "release ${BUILD_VERSION}" dist
pre-release: ## github pre-release
ghr -u ysicing -t $(GITHUB_RELEASE_TOKEN) -replace -prerelease --debug ${BUILD_VERSION} -n "release ${BUILD_VERSION}" dist
clean: ## clean
rm -rf dist
install: clean ## install
go install \
-ldflags "-X 'github.com/ysicing/ergo/cmd.Version=${BUILD_VERSION}' \
-X 'github.com/ysicing/ergo/cmd.BuildDate=${BUILD_DATE}' \
-X 'github.com/ysicing/ergo/cmd.CommitID=${COMMIT_SHA1}'"
.PHONY : build release clean install
.EXPORT_ALL_VARIABLES:
GO111MODULE = on
GOPROXY = https://goproxy.cn
GOSUMDB = sum.golang.google.cn