diff options
-rw-r--r-- | scripts/gh-list.py | 5 | ||||
-rw-r--r-- | scripts/gh-push.py | 22 |
2 files changed, 16 insertions, 11 deletions
diff --git a/scripts/gh-list.py b/scripts/gh-list.py index 1966db4..f8b1c91 100644 --- a/scripts/gh-list.py +++ b/scripts/gh-list.py @@ -1,10 +1,11 @@ +#!/usr/bin/env python + from gh import gh, pr import os tok = os.getenv('GITHUB_TOKEN') -draft = [r for r in gh('releases') - if r['draft'] and r['name'] == 'AUTO'][0] +draft = [r for r in gh('releases') if r['draft']][0] for a in draft['assets']: print(a['browser_download_url'] + diff --git a/scripts/gh-push.py b/scripts/gh-push.py index 3aedb15..dd3b940 100644 --- a/scripts/gh-push.py +++ b/scripts/gh-push.py @@ -1,30 +1,34 @@ -import sys, re -from gh import gh, get_release +#!/usr/bin/env python + +import sys, os, re +from gh import gh if len(sys.argv) != 2: print("Usage: python gh-push.py FILENAME") sys.exit(1) f = sys.argv[1] +fname = os.path.basename(f) -print('Pulling info on release AUTO.') -draft = get_release('AUTO') +print('Pulling info on draft release...') +draft = [r for r in gh('releases') if r['draft']][0] +print('Found: ' + draft['name']) -existing = [a for a in draft['assets'] if a['name'] == f] +existing = [a for a in draft['assets'] if a['name'] == fname] if (len(existing) > 0): - print('Asset exists, deleting.') + print('Asset %s exists, deleting.' % fname) gh('releases/assets/' + str(existing[0]['id']), ['-X', 'DELETE']) -print('Uploading new asset...') +print('Uploading %s...' % f) upload_url = re.sub( - '\\{.*\\}', '?name=' + f, + '\\{.*\\}', '?name=' + fname, draft['upload_url']) resp = gh(upload_url, [ '-H', 'Content-type: application/octet-stream', - '--data-binary', f + '--data-binary', '@' + f ]) print('Done.') |