Skip to content

Instantly share code, notes, and snippets.

@fujiwara
Created November 27, 2017 04:53
Show Gist options
  • Save fujiwara/38b0843a835a7b71ab5495eefc3289cd to your computer and use it in GitHub Desktop.
Save fujiwara/38b0843a835a7b71ab5495eefc3289cd to your computer and use it in GitHub Desktop.
Download GitHub private repo's release files.
#!/bin/bash
set -eu
repo="$1" # fujiwara/foo
tag="$2" # v0.1.0
name="$3" # foo-0.1.1-linux-amd64.zip
releases=$(curl -s -H "Authorization: token ${TOKEN}" "https://api.github.com/repos/${repo}/releases/tags/${tag}")
url=$(echo "$releases" | jq -r ".assets[] | select(.name == \"${name}\").url")
echo $url
download_url=$(echo $url | perl -pE 's{https://}{https://$ENV{"TOKEN"}@}')
curl -sL -H "Accept: application/octet-stream" "$download_url" > "$name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment