Skip to content

Instantly share code, notes, and snippets.

@eahrold
Created July 12, 2014 04:06
Show Gist options
  • Save eahrold/421c82dafb00d57cc99c to your computer and use it in GitHub Desktop.
Save eahrold/421c82dafb00d57cc99c to your computer and use it in GitHub Desktop.
get the URL for the uploaded dmg, zip, or gzip from the latest release using api.github.com
import json
import urllib2
def github_latest_release(user,repo):
SUPPORTED_TYPES=['dmg','zip','gz']
DEST=str(u'https://api.github.com/repos/%s/%s/releases' % (user,repo))
data = json.load(urllib2.urlopen(DEST))
try:
latest_release = data[0]['assets'][0]['browser_download_url']
for t in SUPPORTED_TYPES:
if latest_release.lower().endswith(t):
return latest_release
except:
pass
return None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment