Updated bash scripts to automatically upload files to github.
This commit is contained in:
parent
8378130388
commit
3a5cce43cc
4 changed files with 74 additions and 0 deletions
|
|
@ -18,3 +18,5 @@ rm Web2ExeLinux/files/error.log Web2ExeLinux/files/last_project_path.txt Web2Exe
|
|||
|
||||
zip -r -9 Web2ExeLinux-CMD.zip Web2ExeLinux-CMD/*
|
||||
zip -r -9 Web2ExeLinux-${VERSION}.zip Web2ExeLinux
|
||||
|
||||
python upload_release.py
|
||||
|
|
|
|||
|
|
@ -30,3 +30,5 @@ rm -rf build dist
|
|||
|
||||
/Applications/Keka.app/Contents/Resources/keka7z a -r Web2ExeMac-CMD.zip Web2ExeMac-CMD
|
||||
/Applications/Keka.app/Contents/Resources/keka7z a -r Web2ExeMac-${VERSION}.zip Web2Executable.app
|
||||
|
||||
python upload_release.py
|
||||
|
|
|
|||
|
|
@ -24,3 +24,5 @@ cd command_line_builds
|
|||
7z a ..\Web2ExeWin-CMD.zip -tzip -r *
|
||||
cd ..
|
||||
7z a Web2Exe-Setup.zip Web2Exe-Setup.exe
|
||||
|
||||
call python upload_release.py
|
||||
|
|
|
|||
68
upload_release.py
Normal file
68
upload_release.py
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import requests
|
||||
import json
|
||||
from pprint import pprint
|
||||
from glob import glob
|
||||
|
||||
from semantic_version import Version
|
||||
import getpass
|
||||
import sys
|
||||
|
||||
def main():
|
||||
|
||||
version = ""
|
||||
with open('files/version.txt') as f:
|
||||
version = f.read().strip()
|
||||
|
||||
base_url = 'https://api.github.com/repos/jyapayne/Web2Executable/releases'
|
||||
|
||||
req = requests.get(base_url+'/tags/'+version)
|
||||
|
||||
update = False
|
||||
rel_id = None
|
||||
upload_url = None
|
||||
|
||||
github_user = raw_input('Github user:')
|
||||
|
||||
password = getpass.getpass('Password:')
|
||||
|
||||
if req.status_code == 200:
|
||||
json_data = json.loads(req.text)
|
||||
tag = json_data.get('tag_name', '')
|
||||
cur_ver = Version(tag[1:-1])
|
||||
new_ver = Version(version[1:-1])
|
||||
if new_ver <= cur_ver:
|
||||
update = True
|
||||
rel_id = json_data['id']
|
||||
upload_url = json_data['upload_url'].replace('{?name,label}', '')
|
||||
|
||||
if not update:
|
||||
data = {'tag_name': version,
|
||||
'target_commitish': 'master',
|
||||
'name': 'Web2Executable ' + version}
|
||||
post_res = requests.post(base_url, data=json.dumps(data), auth=(github_user, password))
|
||||
if post_res.status_code == 201:
|
||||
json_data = json.loads(post_res.text)
|
||||
upload_url = json_data['upload_url'].replace('{?name,label}', '')
|
||||
rel_id = json_data['id']
|
||||
else:
|
||||
print 'Authentication failed!'
|
||||
|
||||
if rel_id:
|
||||
zip_files = glob('*.zip')
|
||||
for zip_file in zip_files:
|
||||
with open(zip_file, 'rb') as zipf:
|
||||
file_data = zipf.read()
|
||||
print 'Uploading file {}...'.format(zip_file)
|
||||
data = {'name': zip_file}
|
||||
headers = {'Content-Type': 'application/zip'}
|
||||
r = requests.post(upload_url, params=data, data=file_data, headers=headers, auth=(github_user, password))
|
||||
if r.status_code == 201:
|
||||
print 'Success!'
|
||||
else:
|
||||
print 'Error:', r.text
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue