Skip to content

Instantly share code, notes, and snippets.

@umohi
Created September 21, 2018 22:48
Show Gist options
  • Save umohi/bfc7ad9a845fc10289c03d532e3d2c2f to your computer and use it in GitHub Desktop.
Save umohi/bfc7ad9a845fc10289c03d532e3d2c2f to your computer and use it in GitHub Desktop.
use curl to download release artifact from github private repository
# in order to download release artifacts from github, you have to first retreive the
# list of asset URLs using the github repo REST API. Use the asset URL to download
# the artifact as a octet-stream data stream. You will need to get an access token
# from "settings -> developer settings -> personal access tokens" on the github UI
#!/bin/bash -e
owner="MY_ORG_NAME"
repo="MY_REPO_NAME"
tag="ARTIFACT_TAG"
artifact="ARTIFACT_NAME"
token="MY_ACCESS_TOKEN"
list_asset_url="https://api.github.com/repos/${owner}/${repo}/releases/tags/${tag}?access_token=${token}"
# get url for artifact with name==$artifact
asset_url=$(curl "${list_asset_url}" | jq ".assets[] | select(.name==\"${artifact}\") | .url" | sed 's/\"//g')
# download the artifact
curl -vLJO -H 'Accept: application/octet-stream' \
"${asset_url}?access_token=${token}"
@frozer
Copy link

frozer commented Feb 18, 2025

Based on @thenets work, I extended his script with GITHUB_TOKEN support, please check - https://gist.github.com/frozer/6dcdf9a901f32688c4e89163a65b17bd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment