Created
July 12, 2014 04:06
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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