forked from hluk/CopyQ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfosshub.py
executable file
·42 lines (35 loc) · 1.21 KB
/
fosshub.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
42
#!/usr/bin/env python
"""
Create new release and upload files to FossHUB.
Get the API key from: https://devzone.fosshub.com/dashboard/profile
USAGE: ./fosshub.py <VERSION> <API_KEY>
"""
import requests
import sys
project_id = '5c1195728c9fe8186f80a14b'
fosshub_new_release_url = 'https://api.fosshub.com/rest/projects/{project_id}/releases/'.format(project_id=project_id)
github_release_url = 'https://github.com/hluk/CopyQ/releases/download/v{version}/{basename}'
files = {
'copyq-{version}-setup.exe': 'Windows Installer',
'copyq-{version}.zip': 'Windows Portable',
'CopyQ.dmg.zip': 'macOS',
}
version = sys.argv[1]
api_key = sys.argv[2]
# https://devzone.fosshub.com/dashboard/restApi
data = {
'version': version,
'files': [{
'fileUrl': github_release_url.format(version=version, basename=basename.format(version=version)),
'type': filetype,
'version': version
} for basename, filetype in files.items()],
'publish': True,
}
headers = {
'X-Auth-Key': api_key
}
response = requests.post(fosshub_new_release_url, json=data, headers=headers)
if response.status_code != 200:
raise RuntimeError('Unexpected response: ' + response.text)
print('All OK: ' + response.text)