diff --git a/scripts/update-appup.sh b/scripts/update-appup.sh index 7c8ef1925..d5f3b5407 100755 --- a/scripts/update-appup.sh +++ b/scripts/update-appup.sh @@ -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