-
Notifications
You must be signed in to change notification settings - Fork 13
/
deploy.py
32 lines (24 loc) · 1.07 KB
/
deploy.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
import os
import json
import logging
from github3 import login
logging.basicConfig(level=logging.DEBUG)
def main(access_token, repo_owner, repo_name, tag, commitish, release_asset, release_asset_type, prerelease=True): # noqa
gh = login(token=access_token)
repo = gh.repository(repo_owner, repo_name)
# create release
release_asset_name = "{}__{}.tar.gz".format(release_asset.name, tag)
release = repo.create_release(tag, commitish, prerelease=prerelease)
release.upload_asset(release_asset_type, release_asset_name, release_asset)
if __name__ == '__main__':
with open(os.getenv('RELEASE_ASSET'), 'rb') as asset, open(os.getenv('PACKAGE_JSON'), 'rt') as pkg_json: # noqa
version = json.load(pkg_json)['version']
main(
access_token=os.getenv('GH_TOKEN'),
repo_owner='masterfacilitylist',
repo_name=os.getenv('CIRCLE_PROJECT_REPONAME'),
tag=version,
commitish=os.getenv('CIRCLE_SHA1'),
release_asset=asset,
release_asset_type='application/x-gzip'
)