From 0b7c99362a8a1e0571c88da454040efa0f9f1014 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sun, 19 Nov 2023 16:21:05 +0200 Subject: [PATCH] ci: improve failure handling in update.sh --- update.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/update.sh b/update.sh index dafb1d5..dd10091 100755 --- a/update.sh +++ b/update.sh @@ -7,6 +7,17 @@ set -o pipefail readarray -t RELEASES <<<"$(curl https://api.github.com/repos/openhab/openhab-distro/tags | jq -r '.[].name' | rg '^\d+\.\d+\.\d+*$')" MOST_RECENT=${RELEASES[0]} +# Sometimes GitHub returns a response containing something unusual, and although `jq` fails with +# the error: +# +# jq: error (at :1): Cannot index string with string "name" +# +# the processing does not stop despite `pipefail`. In those instances `$MOST_RECENT` ends up empty, +# so lets just bail when that happens. +if [[ -z "$MOST_RECENT" ]]; then + exit 1 +fi + echo -n "$MOST_RECENT" > version curl -L https://github.com/openhab/openhab-distro/releases/download/"$MOST_RECENT"/openhab-"$MOST_RECENT".tar.gz \ | sha256sum \