MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / add_release

Function add_release

Scripts/add-github-release.py:14–52  ·  view source on GitHub ↗

Creates a release on GitHub for the given arguments

(token, repo, tag, archive_path, notes)

Source from the content-addressed store, hash-verified

12import sys
13
14def add_release(token, repo, tag, archive_path, notes):
15 '''
16 Creates a release on GitHub for the given arguments
17 '''
18 print('token: "{}", repo: "{}", tag: "{}", archive: "{}" notes: "{}"'.format('SECURE' if token else '', repo, tag, archive_path, notes))
19
20 assert token, 'No API token given'
21 assert repo, 'No repo given'
22 assert '/' in repo, "Repo doesn't look like a valid GitHub repo (e.g. abbeycode/UnrarKit)"
23 assert tag, 'No tag given'
24 assert archive_path, 'No archive path given'
25 assert notes, 'No notes given'
26
27 is_beta = tag_is_beta(tag)
28
29 url = 'https://api.github.com/repos/{}/releases'.format(repo)
30 header = {
31 'Authorization': 'token {}'.format(token)
32 }
33 values = {
34 'tag_name': tag,
35 'name': 'v{}'.format(tag),
36 'body': notes,
37 'prerelease': True if is_beta else False
38 }
39
40 data = json.dumps(values)
41 request = urllib2.Request(url, data, header)
42 response = urllib2.urlopen(request)
43 the_page = response.read()
44
45 response_dict = json.loads(the_page)
46 upload_url = response_dict['upload_url']
47 release_url = response_dict['url']
48
49 upload_carthage_archive(token, upload_url, archive_path)
50
51 print('Release added: {}'.format(release_url))
52 return True
53
54def tag_is_beta(tag):
55 '''

Callers 1

Calls 2

tag_is_betaFunction · 0.85
upload_carthage_archiveFunction · 0.85

Tested by

no test coverage detected