diff --git a/.github/scripts/check_alist.sh b/.github/scripts/check_alist.sh index 1c01a45..35d7e63 100755 --- a/.github/scripts/check_alist.sh +++ b/.github/scripts/check_alist.sh @@ -4,16 +4,35 @@ function to_int() { echo $(echo "$1" | grep -oE '[0-9]+' | tr -d '\n') } -LATEST_VER=$(curl -s https://api.github.com/repos/alist-org/alist/releases/latest | grep -o '"tag_name": ".*"' | cut -d'"' -f4) +function get_latest_version() { + echo $(curl -s https://api.github.com/repos/alist-org/alist/releases/latest | grep -o '"tag_name": ".*"' | cut -d'"' -f4) +} + +LATEST_VER="" +for index in $(seq 5) +do + echo "Try to get latest version, index=$index" + LATEST_VER=$(get_latest_version) + if [ -z $LATEST_VER ]; then + echo "Failed to get latest version, sleep 5s and retry" + sleep 5 + else + break + fi + +done + LATEST_VER_INT=$(to_int $LATEST_VER) echo "Latest AList version $LATEST_VER ${LATEST_VER_INT}" -echo "alist_version=$LATEST_VER" >> $GITHUB_ENV +echo "alist_version=$LATEST_VER" >> $GITHUB_ENV # VERSION_FILE="$GITHUB_WORKSPACE/alist_version.txt" VER=$(cat $VERSION_FILE) + if [ -z $VER ]; then VER="v3.25.1" + echo "No version file, use default version ${VER}" fi VER_INT=$(to_int $VER)