From 5bdb85b04f86c48595109850233692dd2d61fca5 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 9 Mar 2023 17:11:48 +0100 Subject: [PATCH] build: add a script to find previous release version tag --- scripts/apps-version-check.sh | 6 +++++- scripts/find-prev-rel-tag.sh | 21 +++++++++++++++++++++ scripts/rel/cut.sh | 6 +----- scripts/update-appup.sh | 2 +- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100755 scripts/find-prev-rel-tag.sh diff --git a/scripts/apps-version-check.sh b/scripts/apps-version-check.sh index 902251bb9..b86101027 100755 --- a/scripts/apps-version-check.sh +++ b/scripts/apps-version-check.sh @@ -1,7 +1,11 @@ #!/usr/bin/env bash set -euo pipefail -latest_release=$(git describe --abbrev=0 --tags --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*docker*') +# ensure dir +cd -P -- "$(dirname -- "${BASH_SOURCE[0]}")/.." + +# match any official release tag 'e*' and 'v*' +latest_release="$(env PREV_TAG_MATCH_PATTERN='*' ./scripts/find-prev-rel-tag.sh)" echo "Version check compare base: $latest_release" bad_app_count=0 diff --git a/scripts/find-prev-rel-tag.sh b/scripts/find-prev-rel-tag.sh new file mode 100755 index 000000000..8813db2f5 --- /dev/null +++ b/scripts/find-prev-rel-tag.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [ -z "${PREV_TAG_MATCH_PATTERN:-}" ]; then + PROFILE="${PROFILE:-${1:-}}" + case "$PROFILE" in + emqx-enterprise*) + PREV_TAG_MATCH_PATTERN='e*' + ;; + emqx*) + PREV_TAG_MATCH_PATTERN='v*' + ;; + *) + echo "Unknown profile '$PROFILE'" + echo "Usage: $0 PROFILE" + exit 1 + ;; + esac +fi + +git describe --abbrev=0 --tags --match "${PREV_TAG_MATCH_PATTERN}" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*docker*' diff --git a/scripts/rel/cut.sh b/scripts/rel/cut.sh index 728aeddb3..b12c86519 100755 --- a/scripts/rel/cut.sh +++ b/scripts/rel/cut.sh @@ -236,11 +236,7 @@ fi generate_changelog () { local from_tag="${PREV_TAG:-}" if [[ -z $from_tag ]]; then - if [ $PROFILE == "emqx" ]; then - from_tag="$(git describe --tags --abbrev=0 --match 'v*')" - else - from_tag="$(git describe --tags --abbrev=0 --match 'e*')" - fi + from_tag="$(./scripts/find-prev-rel-tag.sh "$PROFILE")" fi ./scripts/rel/format-changelog.sh -b "${from_tag}" -l 'en' -v "$TAG" > "changes/${TAG}.en.md" ./scripts/rel/format-changelog.sh -b "${from_tag}" -l 'zh' -v "$TAG" > "changes/${TAG}.zh.md" diff --git a/scripts/update-appup.sh b/scripts/update-appup.sh index b962c4a9a..2c99c641d 100755 --- a/scripts/update-appup.sh +++ b/scripts/update-appup.sh @@ -40,7 +40,7 @@ esac ## e4.3.11 ## rel-v4.4.3 ## rel-e4.4.3 -PREV_TAG="${PREV_TAG:-$(git describe --tag --abbrev=0 --match "[${TAG_PREFIX}|rel-]*" --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*')}" +PREV_TAG="${PREV_TAG:-$(env PREV_TAG_MATCH_PATTERN="[${TAG_PREFIX}|rel-]*" ./scripts/find-prev-rel-tag.sh)}" shift 1 # bash 3.2 treat empty array as unbound, so we can't use 'ESCRIPT_ARGS=()' here,