Skip to content

Instantly share code, notes, and snippets.

@tru
Created May 9, 2015 06:37
Show Gist options
  • Select an option

  • Save tru/fa32286efae60ea76432 to your computer and use it in GitHub Desktop.

Select an option

Save tru/fa32286efae60ea76432 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import requests
from requests.auth import HTTPBasicAuth
import sys
import json
project_map = {
"plex-home-theater": ("plexinc/plex-home-theater", 2)
}
github_token = ""
if __name__ == "__main__":
project = sys.argv[1]
releaseversion = sys.argv[2]
githashshort = releaseversion[releaseversion.rfind('-') + 1:]
r = requests.get("https://api.github.com/repos/%s/commits/%s" % (project_map[project][0], githashshort), auth=(github_token, "x-oauth-basic"))
commitdata = r.json()
if not "sha" in commitdata:
print "COULD NOT FIND COMMIT %s/%s ON GITHUB" % (project_map[project][0], githashshort)
sys.exit(0)
githash = commitdata["sha"]
print "Full hash is", githash
data = {
"tag_name": "v%s" % releaseversion,
"target_commitish": githash,
"name": "v%s" % releaseversion,
"body": "notes goes here",
"draft": False,
"prerelease": False
}
jsondata = json.dumps(data)
r = requests.post("https://api.github.com/repos/%s/releases" % project_map[project][0], auth=(github_token, "x-oauth-basic"), data=jsondata)
print r.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment