fix(ci):get app_version automatically

get app_version automatically
This commit is contained in:
xiaochenl 2021-04-26 11:07:57 +08:00
parent 2a030a92d4
commit 9a176c75a6
2 changed files with 8 additions and 3 deletions

View File

@ -2,7 +2,6 @@
SHELL := /bin/bash
CURRENT_PATH = $(shell pwd)
APP_NAME = bitxhub
APP_VERSION = 1.6.0
export GODEBUG=x509ignoreCN=0
# build with verison infos
@ -10,6 +9,11 @@ VERSION_DIR = github.com/meshplus/${APP_NAME}
BUILD_DATE = $(shell date +%FT%T)
GIT_COMMIT = $(shell git log --pretty=format:'%h' -n 1)
GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD)
ifeq (${GIT_BRANCH},HEAD)
APP_VERSION = $(shell git describe --tags HEAD)
else
APP_VERSION = dev
endif
GOLDFLAGS += -X "${VERSION_DIR}.BuildDate=${BUILD_DATE}"
GOLDFLAGS += -X "${VERSION_DIR}.CurrentCommit=${GIT_COMMIT}"
@ -83,7 +87,7 @@ buildent:
## make release: Build release before push
release-binary:
@cd scripts && bash release_binary.sh '${APP_VERSION}'
@cd scripts && bash release_binary.sh
mod:
sed "s?)?$(MODS)\n)?" go.mod

View File

@ -5,7 +5,8 @@ source x.sh
CURRENT_PATH=$(pwd)
PROJECT_PATH=$(dirname "${CURRENT_PATH}")
BUILD_PATH=${PROJECT_PATH}/build
APP_VERSION=${1:-'1.6.0'}
# shellcheck disable=SC2046
APP_VERSION=$(if [ `git rev-parse --abbrev-ref HEAD` == 'HEAD' ];then git describe --tags HEAD ; else echo "dev" ; fi)
print_blue "===> 1. Install packr"
if ! type packr >/dev/null 2>&1; then