File: fosshub.py

package info (click to toggle)
copyq 3.7.3-1~bpo9+1
  • links: PTS, VCS
  • area: main
  • in suites: stretch-backports
  • size: 10,480 kB
  • sloc: cpp: 51,894; sh: 734; python: 211; xml: 57; makefile: 34
file content (40 lines) | stat: -rwxr-xr-x 1,163 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/env python
"""
Create new release and upload files to FossHUB.

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-v{version}-setup.exe': 'Windows Installer',
    'copyq-v{version}.zip': 'Windows Portable',
    'CopyQ.dmg': '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)