Create new release note or get the existing one when uploading.
This commit is contained in:
parent
3edfb7d5c3
commit
33c509b867
1 changed files with 41 additions and 15 deletions
|
@ -4,11 +4,13 @@ import argparse
|
||||||
import errno
|
import errno
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
import requests
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
from lib.util import *
|
from lib.util import *
|
||||||
|
from lib.github import GitHub
|
||||||
|
|
||||||
|
|
||||||
TARGET_PLATFORM = {
|
TARGET_PLATFORM = {
|
||||||
|
@ -18,6 +20,7 @@ TARGET_PLATFORM = {
|
||||||
'win32': 'win32',
|
'win32': 'win32',
|
||||||
}[sys.platform]
|
}[sys.platform]
|
||||||
|
|
||||||
|
ATOM_SHELL_REPO = 'atom/atom-shell'
|
||||||
ATOM_SHELL_VRESION = get_atom_shell_version()
|
ATOM_SHELL_VRESION = get_atom_shell_version()
|
||||||
NODE_VERSION = 'v0.10.18'
|
NODE_VERSION = 'v0.10.18'
|
||||||
|
|
||||||
|
@ -34,14 +37,17 @@ def main():
|
||||||
create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
||||||
subprocess.check_call([sys.executable, create_dist])
|
subprocess.check_call([sys.executable, create_dist])
|
||||||
|
|
||||||
bucket, access_key, secret_key = s3_config()
|
github = GitHub(auth_token())
|
||||||
upload(bucket, access_key, secret_key)
|
print create_or_get_release_draft(github, args.version)
|
||||||
if not args.no_update_version:
|
# upload(auth_token)
|
||||||
update_version(bucket, access_key, secret_key)
|
# if not args.no_update_version:
|
||||||
|
# update_version(auth_token)
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description='upload distribution file')
|
parser = argparse.ArgumentParser(description='upload distribution file')
|
||||||
|
parser.add_argument('-v', '--version', help='Specify the version',
|
||||||
|
default=ATOM_SHELL_VRESION)
|
||||||
parser.add_argument('-n', '--no-update-version',
|
parser.add_argument('-n', '--no-update-version',
|
||||||
help='Do not update the latest version file',
|
help='Do not update the latest version file',
|
||||||
action='store_true')
|
action='store_true')
|
||||||
|
@ -62,7 +68,30 @@ def dist_newer_than_head():
|
||||||
return dist_time > int(head_time)
|
return dist_time > int(head_time)
|
||||||
|
|
||||||
|
|
||||||
def upload(bucket, access_key, secret_key, version=ATOM_SHELL_VRESION):
|
def create_or_get_release_draft(github, tag):
|
||||||
|
releases = github.repos(ATOM_SHELL_REPO).releases.get()
|
||||||
|
for release in releases:
|
||||||
|
if release['tag_name'] == tag:
|
||||||
|
return release['id']
|
||||||
|
|
||||||
|
return create_release_draft(github, tag)
|
||||||
|
|
||||||
|
|
||||||
|
def create_release_draft(github, tag):
|
||||||
|
name = 'atom-shell %s' % tag
|
||||||
|
body = ''
|
||||||
|
|
||||||
|
print 'Please enter content for the %s release note:' % name
|
||||||
|
for line in sys.stdin:
|
||||||
|
body += line
|
||||||
|
|
||||||
|
data = dict(tag_name=tag, target_commitish=tag, name=name, body=body,
|
||||||
|
draft=True)
|
||||||
|
r = github.repos(ATOM_SHELL_REPO).releases.post(data=data)
|
||||||
|
return r['id']
|
||||||
|
|
||||||
|
|
||||||
|
def upload(auth_token, version=ATOM_SHELL_VRESION):
|
||||||
os.chdir(DIST_DIR)
|
os.chdir(DIST_DIR)
|
||||||
|
|
||||||
s3put(bucket, access_key, secret_key, DIST_DIR,
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
||||||
|
@ -88,21 +117,18 @@ def upload(bucket, access_key, secret_key, version=ATOM_SHELL_VRESION):
|
||||||
'atom-shell/dist/{0}'.format(NODE_VERSION), [node_lib])
|
'atom-shell/dist/{0}'.format(NODE_VERSION), [node_lib])
|
||||||
|
|
||||||
|
|
||||||
def update_version(bucket, access_key, secret_key):
|
def update_version(auth_token):
|
||||||
prefix = os.path.join(SOURCE_ROOT, 'dist')
|
prefix = os.path.join(SOURCE_ROOT, 'dist')
|
||||||
version = os.path.join(prefix, 'version')
|
version = os.path.join(prefix, 'version')
|
||||||
s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [version])
|
s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [version])
|
||||||
|
|
||||||
|
|
||||||
def s3_config():
|
def auth_token():
|
||||||
config = (os.environ.get('ATOM_SHELL_S3_BUCKET', ''),
|
token = os.environ.get('ATOM_SHELL_GITHUB_TOKEN')
|
||||||
os.environ.get('ATOM_SHELL_S3_ACCESS_KEY', ''),
|
message = ('Error: Please set the $ATOM_SHELL_GITHUB_TOKEN '
|
||||||
os.environ.get('ATOM_SHELL_S3_SECRET_KEY', ''))
|
'environment variable, which is your personal token')
|
||||||
message = ('Error: Please set the $ATOM_SHELL_S3_BUCKET, '
|
assert token, message
|
||||||
'$ATOM_SHELL_S3_ACCESS_KEY, and '
|
return token
|
||||||
'$ATOM_SHELL_S3_SECRET_KEY environment variables')
|
|
||||||
assert all(len(c) for c in config), message
|
|
||||||
return config
|
|
||||||
|
|
||||||
|
|
||||||
def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
||||||
|
|
Loading…
Reference in a new issue