build: add a script to find previous release version tag

This commit is contained in:
Zaiming (Stone) Shi 2023-03-09 17:11:48 +01:00
parent e4ce9e1111
commit 5bdb85b04f
4 changed files with 28 additions and 7 deletions

View File

@ -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

21
scripts/find-prev-rel-tag.sh Executable file
View File

@ -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*'

View File

@ -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"

View File

@ -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,