|
3 | 3 | set -e |
4 | 4 |
|
5 | 5 | REPO="lfdevs/mesa-for-android-container" |
6 | | -API_URL="https://api.github.com/repos/${REPO}/releases/latest" |
7 | 6 |
|
8 | 7 | # Must run as root |
9 | 8 | if [ "$(id -u)" -ne 0 ]; then |
|
67 | 66 | apt-get install -y --no-install-recommends python3 $MESA_PACKAGES |
68 | 67 | fi |
69 | 68 |
|
70 | | -echo "Fetching latest release info from ${REPO}..." |
71 | | - |
72 | | -# Fetch and parse the download URL using python3 |
73 | | -DOWNLOAD_URL=$(python3 - <<EOF |
74 | | -import urllib.request, json, sys |
75 | | -
|
76 | | -try: |
77 | | - with urllib.request.urlopen("${API_URL}") as r: |
78 | | - data = json.load(r) |
79 | | -except Exception as e: |
80 | | - print(f"Error fetching release info: {e}", file=sys.stderr) |
81 | | - sys.exit(1) |
82 | | -
|
83 | | -tag = data.get("tag_name", "unknown") |
84 | | -print(f"Latest release: {tag}", file=sys.stderr) |
85 | | -
|
86 | | -pattern = "${DISTRO_TAG}_${ARCH_TAG}" |
87 | | -for asset in data.get("assets", []): |
88 | | - name = asset.get("name", "") |
89 | | - if pattern in name and name.endswith((".tar.gz", ".tar")): |
90 | | - print(asset["browser_download_url"]) |
91 | | - sys.exit(0) |
92 | | -
|
93 | | -print(f"Error: No asset found matching '{pattern}'", file=sys.stderr) |
94 | | -sys.exit(1) |
95 | | -EOF |
96 | | -) |
| 69 | +# No GitHub API here: unauthenticated calls to it share one rate limit per IP, |
| 70 | +# and GitHub-hosted runners burn through it, so CI died with "403 rate limit |
| 71 | +# exceeded". The releases/latest redirect and the download URL need no API. |
| 72 | +# Assets are named mesa-for-android-container_<version>_<distro>_<arch>, where |
| 73 | +# <version> is the tag without its "mesa-" prefix; Arch's is a plain .tar. |
| 74 | +echo "Resolving the latest release of ${REPO}..." |
| 75 | +TAG=$(curl -fsSLI -o /dev/null -w '%{url_effective}' "https://github.com/${REPO}/releases/latest") |
| 76 | +TAG=${TAG##*/} |
| 77 | +[ -n "$TAG" ] || { echo "Error: could not resolve the latest release"; exit 1; } |
| 78 | +echo "Latest release: ${TAG}" |
| 79 | +EXT=.tar.gz |
| 80 | +[ "$DISTRO_TAG" = archlinux ] && EXT=.tar |
| 81 | +DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG}/mesa-for-android-container_${TAG#mesa-}_${DISTRO_TAG}_${ARCH_TAG}${EXT}" |
97 | 82 |
|
98 | 83 | FILENAME=$(basename "$DOWNLOAD_URL") |
99 | 84 | echo "Found: ${FILENAME}" |
|
0 commit comments