Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Small script to download the binary of a release using curl.
# You can inspect the release by `tag` before to get the URL of the first asset.
# The you can download the release asset file (not the API object) by including the header 'Accept: application/octet-stream'
# NOTE: When downloading the binary file, don't forget to specify the name of the downloaded file (with -o <filename>).
# Otherwise the binary will be streamed into the terminal, doing weird unexpected things.
# Everything put together gives that script:
GITHUB_TOKEN=$GITHUB_TOKEN # Necessary only for private repos
GITHUB_ASSET_ID=$(curl -sSL${GITHUB_OWNER}/${GITHUB_REPO}/releases/tags/${GITHUB_TAG}?access_token=${GITHUB_TOKEN} | grep -B 1 "\"name\": \"${GITHUB_ASSET_FILENAME}\"" | head -1 | sed 's/.*"id": \(.*\),/\1/')
curl -L${GITHUB_OWNER}/${GITHUB_REPO}/releases/assets/${GITHUB_ASSET_ID}?access_token=${GITHUB_TOKEN} -o ${GITHUB_ASSET_FILENAME} -H 'Accept: application/octet-stream'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment