update_retroplayer-addons: improve tag resolution

Make sure we always return the latest tag in the branch and
only apply tag-suffix filtering if more than one tag exists.

This ensures we won't pick up an older (eg -Nexus) tag if newer
(eg -Matrix) tags are present - like it's currently the case with
game addons which only get "-Matrix" tags.

Signed-off-by: Matthias Reichl <hias@horus.com>
This commit is contained in:
Matthias Reichl 2022-01-09 17:14:39 +01:00
parent aef5e1af14
commit da6765db4f
2 changed files with 15 additions and 9 deletions

View File

@ -67,17 +67,23 @@ resolve_hash_on_gh() {
}
resolve_tag_in_branch() {
local tag
local tag tags
if [ -d "$1" ] ; then
cd "$1"
if [ $# -eq 3 ] ; then
tag=$(git describe --abbrev=0 --tags --match "$3" origin/$2 2>/dev/null)
if [ -n "$tag" ] ; then
echo "$tag"
return
fi
tag=$(git describe --abbrev=0 --tags origin/$2 2>/dev/null)
if [ -z "${tag}" ]; then
return
fi
git describe --abbrev=0 --tags origin/$2 2>/dev/null
tags=( $(git tag --points-at "${tag}" | sort -r -n) )
if [ $# -eq 3 -a ${#tags[@]} -gt 1 ]; then
for tag in "${tags[@]}"; do
if [[ "${tag}" =~ $3 ]]; then
echo "$tag"
return
fi
done
fi
echo "${tags[0]}"
fi
}

View File

@ -132,7 +132,7 @@ for addon in ${ADDONS_DIR}/*.*/ ; do
if [ -z "$GITHUB_API_TOKEN" ]; then
git_clone "${GAME_GIT_REPO}" "${GAME_GIT_DIR}"
if [ -n "${TAG_SUFFIX}" ]; then
GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}" "*-${TAG_SUFFIX}")
GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}" ".*-${TAG_SUFFIX}$")
else
GAME_NEW_VERSION=$(resolve_tag_in_branch "${GAME_GIT_DIR}" "${GAME_GIT_BRANCH}")
fi