list-versions-bitbucket: versions not starting with a digit are considered prereleases

This commit is contained in:
Calin Crisan 2018-06-23 23:21:13 +03:00
parent 1e87d81b74
commit ce93017e44

View File

@ -5,6 +5,15 @@ if [ -z "$1" ]; then
exit -1
fi
function check_prerelease() {
read line
if [[ "$line" =~ ^[0-9] ]]; then
echo "$line"
else
echo "$line" | sed 's/|false|/|true|/'
fi
}
extensions=".img.gz .img.xz .img"
opts="-s -S -f"
test -n "$FW_USERNAME" && opts+=" --user $FW_USERNAME:$FW_PASSWORD"
@ -13,6 +22,6 @@ url="https://api.bitbucket.org/2.0/repositories/$1/downloads?pagelen=100&_=$(dat
rtrimstr=$(for e in $extensions; do echo -n " | rtrimstr(\"$e\")"; done)
jq_expr=".values[] | [{a: .name | split(\"-\"), url: .links.self.href}] | map((.a[2] $rtrimstr), \"false\", .a[1], .url) | join(\"|\")"
curl $opts $url | jq --raw-output "$jq_expr"
curl $opts $url | jq --raw-output "$jq_expr" | while read line; do echo "$line" | check_prerelease; done
exit ${PIPESTATUS[0]}