mirror of
https://codefloe.com/Jonas8272/scoop-bucket.git
synced 2026-12-01 00:19:36 +00:00
socialstreamninja: track pre-release (test) builds instead of stable only
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01XFn3QekarqiDEYnrbupCyz
This commit is contained in:
1 parent
1bff9d28d5
commit
460c1aef74
2 files changed
+30
-16
No files matched your search
@@ -13,9 +13,14 @@
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
"persist": "SocialStreamNinja-data",
|
"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": {
|
"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": {
|
"autoupdate": {
|
||||||
"url": "https://github.com/steveseguin/social_stream/releases/download/v$version/socialstreamninja-portable.exe"
|
"url": "https://github.com/steveseguin/social_stream/releases/download/v$version/socialstreamninja-portable.exe"
|
||||||
|
|||||||
@@ -3,41 +3,50 @@ set -euo pipefail
|
|||||||
|
|
||||||
M=bucket/socialstreamninja.json
|
M=bucket/socialstreamninja.json
|
||||||
REPO=steveseguin/social_stream
|
REPO=steveseguin/social_stream
|
||||||
ASSET='^socialstreamninja-portable\.exe$'
|
ASSET=socialstreamninja-portable.exe
|
||||||
|
|
||||||
auth=()
|
auth=()
|
||||||
if [ -n "${GH_API_TOKEN:-}" ]; then
|
if [ -n "${GH_API_TOKEN:-}" ]; then
|
||||||
auth=(-H "Authorization: Bearer $GH_API_TOKEN")
|
auth=(-H "Authorization: Bearer $GH_API_TOKEN")
|
||||||
fi
|
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")
|
tag=$(jq -r .tag_name <<<"$rel")
|
||||||
ver=${tag#v}
|
ver=${tag#v}
|
||||||
cur=$(jq -r .version "$M")
|
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)"
|
echo "up to date ($cur)"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
name=$(jq -r '.assets[].name' <<<"$rel" | grep -E "$ASSET" || true)
|
url="https://github.com/$REPO/releases/download/$tag/$ASSET"
|
||||||
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"
|
|
||||||
|
|
||||||
# Prefer GitHub's recorded digest; otherwise download and hash the file.
|
# 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
|
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"
|
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)
|
hash=$(sha256sum /tmp/asset | cut -d' ' -f1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jq --indent 4 --arg v "$ver" --arg u "$url" --arg h "$hash" \
|
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"
|
'.version=$v | .url=$u | .hash=$h' "$M" > "$M.tmp" && mv "$M.tmp" "$M"
|
||||||
|
|
||||||
echo "updated $cur -> $ver"
|
echo "updated $cur -> $ver ($(jq -r .prerelease <<<"$rel" | sed 's/true/pre-release/; s/false/stable/'))"
|
||||||
Reference in new issue
Block a user