bash script to download the latest release asset of any GitHub repo (e.g., llama.cpp) A developer shared a bash script that automatically downloads the latest release asset from any GitHub repository, using llama.cpp as an example. The script fetches the latest release URL from the GitHub API, downloads the matching asset, extracts it, and cleans up. | /usr/bin/env bash | | | set -euo pipefail | | | REPO="ggml-org/llama.cpp" | | | PATTERN='https:// ^" llama-b 0-9 +-bin-win-cuda-12\.4-x64\.zip' | | | API URL="https://api.github.com/repos/$REPO/releases/latest" | | | DOWNLOAD URL=$ curl -s "$API URL" | grep -oE "$PATTERN" | head -1 | | | if -z "$DOWNLOAD URL" ; then | | | echo "Error: No asset matching '$PATTERN' found in latest release of $REPO" &2 | | | exit 1 | | | fi | | | FILENAME=$ basename "$DOWNLOAD URL" | | | DIRNAME="${FILENAME%. }" | | | echo "Downloading $FILENAME ..." | | | curl - -L "$DOWNLOAD URL" -o "$FILENAME" | | | echo "Extracting to $DIRNAME/" | | | unzip -q "$FILENAME" -d "$DIRNAME" | | | echo "Removing $FILENAME" | | | rm "$FILENAME" | | | echo "Done Files in: $DIRNAME/" |