File: github.release.py

package info (click to toggle)
xca 2.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,328 kB
  • sloc: cpp: 30,584; sh: 341; xml: 74; makefile: 56; python: 34
file content (45 lines) | stat: -rwxr-xr-x 1,066 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
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 token 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)