forked from TencentBlueKing/bk-hcm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
84 lines (69 loc) · 2.54 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
# version
PRO_DIR = $(shell pwd)
BUILDTIME = $(shell date +%Y-%m-%dT%T%z)
VERSION = $(shell echo ${ENV_BK_HCM_VERSION})
DEBUG = $(shell echo ${ENV_BK_HCM_ENABLE_DEBUG})
# output directory for release package and version for command line
ifeq ("$(VERSION)", "")
export OUTPUT_DIR = ${PRO_DIR}/build/bk-hcm
export LDVersionFLAG = "-X hcm/pkg/version.BUILDTIME=${BUILDTIME} \
-X hcm/pkg/version.DEBUG=${DEBUG}"
else
GITHASH = $(shell git rev-parse HEAD)
export OUTPUT_DIR = ${PRO_DIR}/build/bk-hcm-${VERSION}
export LDVersionFLAG = "-X hcm/pkg/version.VERSION=${VERSION} \
-X hcm/pkg/version.BUILDTIME=${BUILDTIME} \
-X hcm/pkg/version.GITHASH=${GITHASH} \
-X hcm/pkg/version.DEBUG=${DEBUG}"
endif
export GO111MODULE=on
include ./scripts/makefile/uname.mk
default: all
pre:
@echo -e "\e[34;1mBuilding...\n\033[0m"
mkdir -p ${OUTPUT_DIR}
all: pre ui server
@cd ${PRO_DIR}/cmd && make
@echo -e "\e[34;1mBuild All Success!\n\033[0m"
server: pre
@cd ${PRO_DIR}/cmd && make
@echo -e "\e[34;1mBuild Server Success!\n\033[0m"
package: pre ui api ver
@echo -e "\e[34;1mPackaging...\n\033[0m"
@mkdir -p ${OUTPUT_DIR}/bin
@mkdir -p ${OUTPUT_DIR}/etc
@mkdir -p ${OUTPUT_DIR}/install
@mkdir -p ${OUTPUT_DIR}/install/sql
@cp -rf ${PRO_DIR}/scripts/sql/* ${OUTPUT_DIR}/install/sql/
@cd ${PRO_DIR}/cmd && make package
@echo -e "\e[34;1mPackage All Success!\n\033[0m"
docker: pre ui ver
@echo -e "\e[34;1mMake Dockering...\n\033[0m"
@cp -rf ${PRO_DIR}/docs/support-file/docker/* ${OUTPUT_DIR}/
@mv ${OUTPUT_DIR}/front ${OUTPUT_DIR}/bk-hcm-webserver/
@cp -rf ${PRO_DIR}/scripts/sql ${OUTPUT_DIR}/bk-hcm-dataservice/
@cd ${PRO_DIR}/cmd && make docker
@echo -e "\e[34;1mMake Docker All Success!\n\033[0m"
ui: pre
@echo -e "\e[34;1mBuilding Front...\033[0m"
@cd ${PRO_DIR}/front && npm i && npm run build
@mv ${PRO_DIR}/front/dist ${OUTPUT_DIR}/front
@echo -e "\e[34;1mBuild Front Success!\n\033[0m"
api: pre
@echo -e "\e[34;1mPackaging API Docs...\033[0m"
@mkdir -p ${OUTPUT_DIR}/api/
@mkdir -p ${OUTPUT_DIR}/api/api-server
@cp -f docs/api-docs/api-server/api/bk_apigw_resources_bk-hcm.yaml ${OUTPUT_DIR}/api/api-server
@tar -czf ${OUTPUT_DIR}/api/api-server/zh.tgz -C docs/api-docs/api-server/docs zh
@echo -e "\e[34;1mPackaging API Docs Done\n\033[0m"
ver: pre
@echo ${VERSION} > ${OUTPUT_DIR}/VERSION
@cp -rf ${PRO_DIR}/CHANGELOG.md ${OUTPUT_DIR}
clean:
@cd ${PRO_DIR}/cmd && make clean
@rm -rf ${PRO_DIR}/build
init-tools:
# for golangci-lint
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
lint:
golangci-lint run