Merge pull request #7426 from zmstone/chore-fix-appup-update-script

chore: fix appup update script
This commit is contained in:
Zaiming (Stone) Shi 2022-03-28 17:39:55 +02:00 committed by GitHub
commit 4991dcbe3b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 5 deletions

View File

@ -16,12 +16,15 @@ cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
PROFILE="${1:-}"
case "$PROFILE" in
emqx-ee)
GIT_REPO='emqx/emqx-enterprise.git'
TAG_PREFIX='e'
;;
emqx)
GIT_REPO='emqx/emqx.git'
TAG_PREFIX='v'
;;
emqx-edge)
GIT_REPO='emqx/emqx.git'
TAG_PREFIX='v'
;;
*)
@ -36,7 +39,7 @@ esac
## e4.3.11
## rel-v4.4.3
## rel-e4.4.3
PREV_TAG="$(git describe --tag --abbrev=0 --match "[${TAG_PREFIX}|rel-]*" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*')"
PREV_TAG="${PREV_TAG:-$(git describe --tag --abbrev=0 --match "[${TAG_PREFIX}|rel-]*" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*')}"
shift 1
# bash 3.2 treat empty array as unbound, so we can't use 'ESCRIPT_ARGS=()' here,
@ -75,16 +78,23 @@ if [ "${SKIP_BUILD:-}" != 'yes' ]; then
make "${PROFILE}"
fi
PREV_DIR_BASE="/tmp/emqx-appup-build"
PREV_DIR_BASE="/tmp/_w"
mkdir -p "${PREV_DIR_BASE}"
if [ ! -d "${PREV_TAG}" ]; then
if [ ! -d "${PREV_DIR_BASE}/${PREV_TAG}" ]; then
cp -R . "${PREV_DIR_BASE}/${PREV_TAG}"
# always 'yes' in CI
NEW_COPY='yes'
else
NEW_COPY='no'
fi
pushd "${PREV_DIR_BASE}/${PREV_TAG}"
git reset --hard
if [ "$NEW_COPY" = 'no' ]; then
REMOTE="$(git remote -v | grep "${GIT_REPO}" | head -1 | awk '{print $1}')"
git fetch "$REMOTE"
fi
git clean -fdx
git checkout "${PREV_TAG}"
make clean-all
make "$PROFILE"
popd