diff options
author | Aleks Kissinger <aleks0@gmail.com> | 2019-01-14 08:16:09 +0100 |
---|---|---|
committer | Aleks Kissinger <aleks0@gmail.com> | 2019-01-14 08:16:09 +0100 |
commit | 515cef87a1b676ad09b1fc2243815ffe3310b221 (patch) | |
tree | 8872c7b4d0a9a977d2b53949013cde2c2ef461c5 /scripts/gh-push.py | |
parent | 0efa4c0d62e07c0864ab1d88fbc545f769698044 (diff) |
fixed curl invokation in github scripts
Diffstat (limited to 'scripts/gh-push.py')
-rw-r--r-- | scripts/gh-push.py | 22 |
1 files changed, 13 insertions, 9 deletions
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.') |