diff --git a/.gitignore b/.gitignore index 8fcc220b..c535d6e5 100644 --- a/.gitignore +++ b/.gitignore @@ -31,7 +31,6 @@ /ui/package-lock.json /demo/mock/output/ /upload/ -/tmp/cache/.data.db /tmp/.temp.yaml /tmp/.default.yaml /tmp/.config.yaml diff --git a/.zd.conf b/.zd.conf index 8cd42766..47cdaf33 100644 --- a/.zd.conf +++ b/.zd.conf @@ -1,3 +1,3 @@ -Version = +Version = 3.1 Language = zh diff --git a/Makefile b/Makefile index 95f139c8..4c72fcbd 100644 --- a/Makefile +++ b/Makefile @@ -1,42 +1,26 @@ -VERSION=$(head -n 1 VERSION) -PROJECT=zd - -ifeq ($(OS),Windows_NT) - OS="Windows" -else - ifeq ($(shell uname),Darwin) - OS="Mac" - else - OS="Unix" - endif -endif - -QINIU_DIR="${HOME}/work/zentao/qiniu/" - -QINIU_DIST_DIR=${QINIU_DIR}${PROJECT}/${VERSION}/ -PACKAGE=${PROJECT}-${VERSION} -BIN_DIR=bin -BIN_ZIP_DIR=${BIN_DIR}/zip/${PROJECT}/${VERSION}/ -BIN_OUT=${BIN_DIR}/${PROJECT}/${VERSION}/ -CLIENT_OUT_DIR=client/out/ - -CLIENT_BIN_DIR=client/bin/ -CLIENT_OUT_DIR=client/out/ -CLIENT_OUT_DIR_EXECUTABLE=${CLIENT_OUT_DIR}executable/ -CLIENT_OUT_DIR_UPGRADE=${CLIENT_OUT_DIR}upgrade/ - -CLIENT_UI_DIR=client/ui/ - -COMMAND_MAIN_DIR=cmd/command/ -COMMAND_MAIN_FILE=${COMMAND_MAIN_DIR}main.go - -SERVER_MAIN_FILE=cmd/server/main.go - -BUILD_TIME=`git show -s --format=%cd` -GO_VERSION=`go version` -GIT_HASH=`git show -s --format=%H` -BUILD_CMD_UNIX=go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" -BUILD_CMD_WIN=go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" +.EXPORT_ALL_VARIABLES: +VERSION := $(shell head -n 1 VERSION) +PROJECT := zd +QINIU_DIR := "${HOME}/work/zentao/qiniu/" +QINIU_DIST_DIR := ${QINIU_DIR}${PROJECT}/${VERSION}/ +PACKAGE := ${PROJECT}-${VERSION} +BIN_DIR := bin +BIN_ZIP_DIR := ${BIN_DIR}/zip/${PROJECT}/${VERSION}/ +BIN_OUT := ${BIN_DIR}/${PROJECT}/${VERSION}/ +CLIENT_OUT_DIR := client/out/ +CLIENT_BIN_DIR := client/bin/ +CLIENT_OUT_DIR := client/out/ +CLIENT_OUT_DIR_EXECUTABLE := ${CLIENT_OUT_DIR}executable/ +CLIENT_OUT_DIR_UPGRADE := ${CLIENT_OUT_DIR}upgrade/ +CLIENT_UI_DIR := client/ui/ +COMMAND_MAIN_DIR := cmd/command/ +COMMAND_MAIN_FILE := ${COMMAND_MAIN_DIR}main.go +SERVER_MAIN_FILE := cmd/server/main.go +BUILD_TIME := $(shell git show -s --format=%cd) +GO_VERSION := $(go version) +GIT_HASH := $(git show -s --format=%H) +BUILD_CMD_UNIX := go build -ldflags "-X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" +BUILD_CMD_WIN := go build -ldflags "-s -w -X 'main.AppVersion=${VERSION}' -X 'main.BuildTime=${BUILD_TIME}' -X 'main.GoVersion=${GO_VERSION}' -X 'main.GitHash=${GIT_HASH}'" default: clear build_ui prepare_build compile_all copy_files package package_upgrade clear: @@ -292,11 +276,9 @@ package_upgrade: done update_version_in_config: -ifeq ($(OS),"Mac") - @gsed -i "s/Version.*/Version = ${VERSION}/" .zd.conf -else + @echo 'update version in config ${VERSION}' + @echo 'gen version' @sed -i "s/Version.*/Version = ${VERSION}/" .zd.conf -endif gen_version_file: @echo 'gen version' diff --git a/Taskfile.yml b/Taskfile.yml index debdd4cc..61f9b8a7 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -5,13 +5,24 @@ version: '3' vars: GOOS: $(go env GOOS) GOARCH: $(go env GOARCH) + BIN_DIR: bin + CLIENT_OUT_DIR: client/out + CLIENT_BIN_DIR: client/bin + QINIU_DIR: .release/qiniu VERSION: sh: head -n 1 VERSION PROJECT: zd + GO_VERSION: + sh: go version BUILD_TIME: sh: git show -s --format=%cd GIT_HASH: sh: git show -s --format=%H + LDFLAGS: "-w -s \ + -X 'main.AppVersion={{.VERSION}}' \ + -X 'main.BuildTime={{.BUILD_TIME}}' \ + -X 'main.GoVersion={{.GO_VERSION}' \ + -X 'main.GitHash={{.GIT_HASH}}'" tasks: gofmt: @@ -35,3 +46,73 @@ tasks: desc: build ui cmds: - cd ui && yarn install && yarn build --dest ../client/ui + + clear: + desc: clear + cmds: + - rm -rf {{.BIN_DIR}} + - rm -rf {{.CLIENT_OUT_DIR}} + + update_version_in_config: + desc: update_version_in_config + cmds: + - sed -i "s/Version.*/Version = {{.VERSION}}/" .zd.conf + + gen_version_file: + desc: gen_version_file + cmds: + - echo 'gen version' + - mkdir -p {{.QINIU_DIR}}/{{.PROJECT}}/ + - echo '{"version":"{{.VERSION}}"}' > {{.QINIU_DIR}}/{{.PROJECT}}/version.json + + prepare_res: + desc: prepare_res + cmds: + - echo 'start prepare res' + - cp res/zh/sample.yaml demo/default.yaml + - rm -rf {{.BIN_DIR}} + + prepare_build: + desc: prepare_build + cmds: + - task: clear + - task: update_version_in_config + - task: gen_version_file + - task: prepare_res + + compile_all: + desc: compile_all + cmds: + - task: compile_linux + + compile_linux: + desc: compile_linux + cmds: + - task: compile_server_linux + - task: package_gui_linux_client + - task: compile_command_linux + + compile_server_linux: + desc: compile_server_linux + cmds: + - echo 'start compile server linux' + - rm -rf {{.BIN_DIR}}/linux/server + - GOOS=linux GOARCH=amd64 go build -ldflags "{{.LDFLAGS}}" -o {{.BIN_DIR}}/linux/server cmd/server/main.go + + package_gui_linux_client: + desc: package_gui_linux_client + cmds: + - echo 'start package gui linux' + - rm -rf {{.CLIENT_BIN_DIR}}/* && mkdir -p {{.CLIENT_BIN_DIR}}linux + - cp -rf {{.BIN_DIR}}/linux/server {{.CLIENT_BIN_DIR}}linux/server + - cd client && npm run package-linux && cp -r icon out/{{.PROJECT}}-linux-x64 && cd .. + + default: + cmds: + - task: clear + - task: build_ui + - task: prepare_build + - task: compile_all + - task: copy_files + - task: package + - task: package_upgrade diff --git a/tmp/cache/.data.db b/tmp/cache/.data.db new file mode 100644 index 00000000..8b2c2289 Binary files /dev/null and b/tmp/cache/.data.db differ