ci: improve failure handling in update.sh

This commit is contained in:
Simonas Kazlauskas
2023-11-19 16:21:05 +02:00
parent 59ea36ab59
commit 0b7c99362a

View File

@@ -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 <stdin>: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 \