-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.py
executable file
·44 lines (33 loc) · 1.02 KB
/
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
#!/usr/bin/env python
from argparse import ArgumentParser
from examples.basic_github import GitHub
from setup import VERSION
def parse_args():
parser = ArgumentParser(description='Create a Draft release in GitHub')
parser.add_argument(
'-t', '--token',
help='API token (env GITHUB_TOKEN) with repo:public_repo access')
return parser.parse_args()
def main(args):
version = 'v' + VERSION
gh = GitHub(token=args.token)
# https://developer.github.com/v3/repos/releases/
slug = 'gulducat/basic-api/releases'
released = [
r['name']
for r in gh.get.repos[slug]()
]
if version in released:
print(version + ' already exists')
return
draft = gh.post.repos[slug](json=dict(
tag_name=version,
name=version,
body='💃',
draft=True,
))
tag = draft['html_url'].split('/')[-1]
url = 'https://github.com/%s/edit/%s' % (slug, tag)
print('Draft release: ' + url)
if __name__ == '__main__':
main(parse_args())