forked from chris2511/xca
-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.release.py
executable file
·45 lines (35 loc) · 1.04 KB
/
github.release.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
43
44
45
#!/usr/bin/python3
import sys
import requests
import json
import os
import re
readme = open("README.md", "r").read() #.replace('\n', '\\n').replace('"','\\"')
user = "chris2511"
if len(sys.argv) < 2:
print("Usage: " + sys.argv[0] + " <VERSION> full-path-binaries ... ")
exit(1)
version = sys.argv[1]
url = 'https://api.github.com/repos/' + user + '/xca/releases'
data = {
"tag_name" : "RELEASE." + version,
"target_commitish": "master",
"name": "XCA " + version,
"body": readme,
"draft": True,
"prerelease": True
}
passwd = input("Github Password for " + user + ": ")
r = []
response = requests.post(url, json=data, auth=(user, passwd))
r.append(response.json())
upload_url = response.json().get('upload_url')
print(upload_url)
headers = {'Content-Type': 'text/plain'}
for file in sys.argv[2:]:
name = re.sub(".*/", "", file)
url = upload_url.replace("{?name,label}", "?name=" + name)
print("Upload", file)
response = requests.post(url, headers=headers, data=open(file, 'rb'), auth=(user, passwd))
r.append(response.json())
print(r)