Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,22 @@ LATEST_URL="https://api.github.com/repos/${REPO}/releases/latest"
RELEASE_JSON=$(curl -fsSL "$LATEST_URL") || error "Failed to fetch release info from GitHub."

# Extract the DMG download URL
DMG_URL=$(printf '%s' "$RELEASE_JSON" | grep -o '"browser_download_url":\s*"[^"]*\.dmg"' | head -1 | sed 's/.*"browser_download_url":\s*"//;s/"$//')

if [ -z "$DMG_URL" ]; then
error "No DMG found in the latest release. Please install manually from https://github.com/${REPO}/releases"
fi

VERSION=$(printf '%s' "$RELEASE_JSON" | grep -o '"tag_name":\s*"[^"]*"' | head -1 | sed 's/.*"tag_name":\s*"//;s/"$//')
# POSIX character classes only β€” BSD grep/sed on macOS don't support \s
# (grep tolerates it, sed silently fails to strip, yielding malformed URLs).
DMG_URL=$(printf '%s' "$RELEASE_JSON" \
| grep -o '"browser_download_url"[[:space:]]*:[[:space:]]*"[^"]*\.dmg"' \
| head -1 \
| sed 's/.*"\(https[^"]*\)".*/\1/')

case "$DMG_URL" in
https://*) ;;
*) error "Could not parse the DMG download URL from the GitHub API response. Please install manually from https://github.com/${REPO}/releases" ;;
esac

VERSION=$(printf '%s' "$RELEASE_JSON" \
| grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' \
| head -1 \
| sed 's/.*"\([^"]*\)"$/\1/')
info "Latest version: ${VERSION}"

# ── Download ──────────────────────────────────────────────────────
Expand Down