Skip to content

Commit 156d664

Browse files
fix: build script
1 parent ddbb6f1 commit 156d664

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

.github/workflows/build-release.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
if: matrix.platform == 'macos-latest'
5252
env:
5353
BUNDLE_PYTHON: 1
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5455
run: |
5556
cd desktop
5657
bash scripts/setup-python-bundle.sh

desktop/scripts/setup-python-bundle.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,29 @@ esac
4747

4848
# --- 3. Resolve latest install_only tarball URL ---
4949
echo "Resolving latest python-build-standalone ($TRIPLE) ..."
50-
API_URL="https://api.github.com/repos/$REPO/releases/latest"
5150
# Use GITHUB_TOKEN in CI to avoid rate limits (unauthenticated = 60/hr)
5251
CURL_API=(curl -sL)
5352
if [ -n "${GITHUB_TOKEN:-}" ]; then
5453
CURL_API+=(-H "Authorization: Bearer $GITHUB_TOKEN")
5554
fi
56-
if command -v jq &>/dev/null; then
57-
# (.assets // []) handles API errors or rate limits where .assets may be null
58-
ASSET_URL=$("${CURL_API[@]}" "$API_URL" | jq -r --arg t "$TRIPLE" '(.assets // [])[] | select(.name | test("install_only")) | select(.name | test($t)) | .browser_download_url' | head -1)
59-
else
60-
ASSET_URL=$("${CURL_API[@]}" "$API_URL" | grep -o '"browser_download_url": "[^"]*install_only[^"]*'"$TRIPLE"'[^"]*"' | head -1 | sed 's/.*: "\(.*\)".*/\1/')
55+
fetch_asset_url() {
56+
local json="$1"
57+
if command -v jq &>/dev/null; then
58+
echo "$json" | jq -r --arg t "$TRIPLE" '(.assets // [])[] | select(.name | test("install_only")) | select(.name | test($t)) | .browser_download_url' | head -1
59+
else
60+
echo "$json" | grep -o '"browser_download_url": "[^"]*install_only[^"]*'"$TRIPLE"'[^"]*"' | head -1 | sed 's/.*: "\(.*\)".*/\1/'
61+
fi
62+
}
63+
# Try /releases/latest first
64+
ASSET_URL=$(fetch_asset_url "$("${CURL_API[@]}" "https://api.github.com/repos/$REPO/releases/latest")")
65+
# Fallback: list releases and use first (in case "latest" is missing or rate-limited)
66+
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then
67+
echo " Latest failed, trying list releases..."
68+
if command -v jq &>/dev/null; then
69+
ASSET_URL=$("${CURL_API[@]}" "https://api.github.com/repos/$REPO/releases?per_page=5" | jq -r --arg t "$TRIPLE" '.[0] | (.assets // [])[] | select(.name | test("install_only")) | select(.name | test($t)) | .browser_download_url' | head -1)
70+
else
71+
ASSET_URL=$("${CURL_API[@]}" "https://api.github.com/repos/$REPO/releases?per_page=5" | grep -o '"browser_download_url": "[^"]*install_only[^"]*'"$TRIPLE"'[^"]*"' | head -1 | sed 's/.*: "\(.*\)".*/\1/')
72+
fi
6173
fi
6274
if [ -z "$ASSET_URL" ] || [ "$ASSET_URL" = "null" ]; then
6375
echo "Could not find install_only asset for $TRIPLE. Check https://github.com/$REPO/releases"

0 commit comments

Comments
 (0)