-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuploader.py
41 lines (32 loc) · 977 Bytes
/
uploader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import sys
import os
import tarfile
import shutil
version = os.environ['GITHUB_REF'].split('/')[-1]
print(f'version: {version}')
_, os_name, token = sys.argv
print('token length: ', len(token))
osn = os_name.split('-')[0]
folder_name = os.path.realpath('./dist/qmlview/')
# Build archives
if os_name == 'windows-latest':
# zip file
old_file = shutil.make_archive('qmlview', 'zip', folder_name)
filename = f'qmlview_{version}_{osn}.zip'
os.rename(old_file, filename)
else:
# tar.gz file
old_file = shutil.make_archive('qmlview', 'gztar', folder_name)
filename = f'qmlview_{version}_{osn}.tar.gz'
os.rename(old_file, filename)
print(f'filename: {filename}')
with open('token.txt', 'w') as tok:
tok.write(token)
print('Finished writing token file')
# Login to GH
cmd = 'gh auth login --with-token < token.txt'
os.system(cmd)
print('Authenticated')
cmd1 = f'gh release upload {version} {filename}'
os.system(cmd1)
print('All Done')