forked from FNALbuild/cms-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create-gh-release.py
executable file
·32 lines (29 loc) · 1.19 KB
/
create-gh-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
#!/usr/bin/env python
from __future__ import print_function
import sys, json
from os.path import expanduser
from _py2with3compatibility import Request, urlopen
from cms_static import GH_CMSSW_ORGANIZATION, GH_CMSSW_REPO
from os import environ
GH_TOKEN = open( expanduser("~/.github-token")).read().strip()
if 'GITHUBTOKEN' in environ:
GH_TOKEN = environ['GITHUBTOKEN']
release_name = sys.argv[1]
branch = sys.argv[2]
print('Creating release:\n %s based on %s' % (release_name, branch))
# creating releases will be available in the next version of pyGithub
params = { "tag_name" : release_name,
"target_commitish" : branch,
"name" : release_name,
"body" : 'cms-bot is going to build this release',
"draft" : False,
"prerelease" : False }
request = Request("https://api.github.com/repos/" + GH_CMSSW_ORGANIZATION + "/" + GH_CMSSW_REPO +"/releases",
headers={"Authorization" : "token " + GH_TOKEN })
request.get_method = lambda: 'POST'
print('--')
try:
print(urlopen( request, json.dumps( params ) ).read())
print("OK release",release_name,"created")
except Exception as e:
print('There was an error while creating the release:\n', e)