From d28b11d6ebbe015cca1d7c6c753861f5d42dd943 Mon Sep 17 00:00:00 2001 From: Paul M Date: Mon, 14 Jul 2025 21:25:37 -0500 Subject: [PATCH] fix: improve GitHub release asset filtering pattern and handle multiple matches --- mastersetup.bash | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mastersetup.bash b/mastersetup.bash index 034f263..360e26d 100755 --- a/mastersetup.bash +++ b/mastersetup.bash @@ -22,14 +22,14 @@ cleanup() { download_latest_deb() { local repo="$1" # GitHub repo (e.g., "Eugeny/tabby") local output="$2" # Output file path (e.g., "/tmp/tabby_amd64.deb") - local pattern="$3" # Optional: regex pattern to filter assets (e.g., "tabby.*amd64.deb") + local pattern="$3" # Optional: regex pattern to filter assets (e.g., "tabby-.*-linux-x64\\.deb") local api_url="https://api.github.com/repos/$repo/releases/latest" local download_url # Fetch the latest release JSON and extract the download URL for the .deb - download_url=$(curl -s -f "$api_url" | jq -r --arg pat "${pattern:-.*\.deb}" \ - '.assets[] | select(.name | test($pat)) | .browser_download_url') - if [[ -z "$download_url" || $? -ne 0 ]]; then + download_url=$(curl -s -f "$api_url" | jq -r --arg pat "${pattern:-.*\\.deb}" \ + '.assets[] | select(.name | test($pat)) | .browser_download_url' | head -n 1) + if [[ -z "$download_url" ]]; then echo "Error: No .deb file found for $repo with pattern '$pattern' or API request failed" >&2 return 1 fi @@ -148,7 +148,7 @@ rm /tmp/joplin_install.sh # Tabby echo "Installing Tabby..." -download_latest_deb "Eugeny/tabby" "/tmp/tabby_amd64.deb" "tabby.*amd64.deb" +download_latest_deb "Eugeny/tabby" "/tmp/tabby_amd64.deb" "tabby-.*-linux-x64\\.deb" if [[ -f "/tmp/tabby_amd64.deb" ]]; then sudo apt install /tmp/tabby_amd64.deb -y else