fix: improve GitHub release asset filtering pattern and handle multiple matches
This commit is contained in:
parent
76d349df68
commit
d28b11d6eb
1 changed files with 5 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue