fix(release): clean release assets + SHA256SUMS URL lookup fix

This commit is contained in:
Jon Chery
2026-08-10 16:56:17 +00:00
parent 1ad6780df1
commit 00efe25ce4
2 changed files with 22 additions and 4 deletions
+21 -3
View File
@@ -201,9 +201,27 @@ info "downloading..."
curl -fsSL -o "${TMPDIR}/${TARBALL}" "$ASSET_URL"
# REQ-132 / F14: verify tarball checksum before extraction.
# Fetch SHA256SUMS from the same release; fail closed on mismatch.
SHA256SUMS_URL="$(dirname "$ASSET_URL")/SHA256SUMS"
if curl -fsSL -o "${TMPDIR}/SHA256SUMS" "$SHA256SUMS_URL" 2>/dev/null; then
# Fetch SHA256SUMS from the same release. For Gitea release-download
# URLs (e.g. /releases/download/vX.Y.Z/...) the SHA256SUMS is a sibling.
# For Gitea attachment URLs (e.g. /attachments/<uuid>) we must look up
# the SHA256SUMS asset by name from the release API.
SHA256SUMS_URL=""
if echo "$ASSET_URL" | grep -q "/releases/download/"; then
SHA256SUMS_URL="$(dirname "$ASSET_URL")/SHA256SUMS"
elif command -v python3 >/dev/null 2>&1; then
# Look up SHA256SUMS asset by name from the release API.
SHA256SUMS_URL="$(curl -fsSL \
"${GITEA_URL}/api/v1/repos/${GITEA_OWNER}/${GITEA_REPO}/releases/tags/${VERSION}" 2>/dev/null \
| python3 -c "
import json,sys
r=json.load(sys.stdin)
for a in r.get('assets',[]):
if a.get('name')=='SHA256SUMS':
print(a.get('browser_download_url',''))
break
" 2>/dev/null || true)"
fi
if [ -n "$SHA256SUMS_URL" ] && curl -fsSL -o "${TMPDIR}/SHA256SUMS" "$SHA256SUMS_URL" 2>/dev/null; then
info "verifying checksum..."
(cd "$TMPDIR" && grep -F "$TARBALL" SHA256SUMS | sha256sum -c -) || {
err "checksum verification failed (REQ-132); refusing to install"