From 460c1aef740391d73f16df5739c179edce331d1b Mon Sep 17 00:00:00 2001 From: Jonas8272 Date: Sun, 22 Nov 2026 18:48:49 +0000 Subject: [PATCH] socialstreamninja: track pre-release (test) builds instead of stable only Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01XFn3QekarqiDEYnrbupCyz --- bucket/socialstreamninja.json | 9 +++++-- scripts/update-socialstreamninja.sh | 37 ++++++++++++++++++----------- 2 files changed, 30 insertions(+), 16 deletions(-) diff --git a/bucket/socialstreamninja.json b/bucket/socialstreamninja.json index 2b43042..f9252b1 100644 --- a/bucket/socialstreamninja.json +++ b/bucket/socialstreamninja.json @@ -13,9 +13,14 @@ ] ], "persist": "SocialStreamNinja-data", - "notes": "Export your settings from the app before updating.", + "notes": [ + "Export your settings from the app before updating.", + "This bucket tracks the pre-release (test) builds of Social Stream Ninja, not only the stable ones." + ], "checkver": { - "github": "https://github.com/steveseguin/social_stream" + "url": "https://api.github.com/repos/steveseguin/social_stream/releases?per_page=10", + "jsonpath": "$[0].tag_name", + "regex": "v([\\d.]+)" }, "autoupdate": { "url": "https://github.com/steveseguin/social_stream/releases/download/v$version/socialstreamninja-portable.exe" diff --git a/scripts/update-socialstreamninja.sh b/scripts/update-socialstreamninja.sh index e23034a..42ffce0 100644 --- a/scripts/update-socialstreamninja.sh +++ b/scripts/update-socialstreamninja.sh @@ -3,41 +3,50 @@ set -euo pipefail M=bucket/socialstreamninja.json REPO=steveseguin/social_stream -ASSET='^socialstreamninja-portable\.exe$' +ASSET=socialstreamninja-portable.exe auth=() if [ -n "${GH_API_TOKEN:-}" ]; then auth=(-H "Authorization: Bearer $GH_API_TOKEN") fi -rel=$(curl -fsSL ${auth[@]+"${auth[@]}"} "https://api.github.com/repos/$REPO/releases/latest") +rels=$(curl -fsSL ${auth[@]+"${auth[@]}"} "https://api.github.com/repos/$REPO/releases?per_page=50") + +# Highest versioned tag (vA.B.C) among ALL non-draft releases, pre-releases and +# test builds included, that already has the portable exe uploaded. +rel=$(jq -c --arg a "$ASSET" ' + [ .[] + | select(.draft == false) + | select(.tag_name | test("^v[0-9]+(\\.[0-9]+)+$")) + | select(any(.assets[]; .name == $a)) ] + | sort_by(.tag_name | ltrimstr("v") | split(".") | map(tonumber)) + | last // empty' <<<"$rels") + +[ -n "$rel" ] || { echo "no release with $ASSET found" >&2; exit 1; } + tag=$(jq -r .tag_name <<<"$rel") ver=${tag#v} cur=$(jq -r .version "$M") -if [ "$ver" = "$cur" ]; then +# Up to date, or the manifest is already ahead (for example a pre-release was +# deleted): leave it alone so it never goes backwards. +if [ "$(printf '%s\n%s\n' "$cur" "$ver" | sort -V | tail -n1)" = "$cur" ]; then echo "up to date ($cur)" exit 0 fi -name=$(jq -r '.assets[].name' <<<"$rel" | grep -E "$ASSET" || true) -if [ "$(printf '%s\n' "$name" | grep -c .)" -ne 1 ]; then - echo "expected exactly one asset matching /$ASSET/ in $tag, got:" >&2 - echo "$name" >&2 - exit 1 -fi - -url="https://github.com/$REPO/releases/download/$tag/$name" +url="https://github.com/$REPO/releases/download/$tag/$ASSET" # Prefer GitHub's recorded digest; otherwise download and hash the file. -hash=$(jq -r --arg n "$name" '.assets[] | select(.name==$n) | .digest // empty' <<<"$rel" | sed 's/^sha256://') +hash=$(jq -r --arg n "$ASSET" '.assets[] | select(.name==$n) | .digest // empty' <<<"$rel" | sed 's/^sha256://') if ! [[ $hash =~ ^[0-9a-f]{64}$ ]]; then - echo "no API digest for $name, downloading to hash it" >&2 + echo "no API digest for $ASSET, downloading to hash it" >&2 curl -fsSL -o /tmp/asset "$url" + [ "$(head -c2 /tmp/asset)" = "MZ" ] || { echo "$ASSET is not an exe" >&2; exit 1; } hash=$(sha256sum /tmp/asset | cut -d' ' -f1) fi jq --indent 4 --arg v "$ver" --arg u "$url" --arg h "$hash" \ '.version=$v | .url=$u | .hash=$h' "$M" > "$M.tmp" && mv "$M.tmp" "$M" -echo "updated $cur -> $ver" \ No newline at end of file +echo "updated $cur -> $ver ($(jq -r .prerelease <<<"$rel" | sed 's/true/pre-release/; s/false/stable/'))"