Add flag for upload script to skip updating version.
When uploading multiple distributions in future, we need to make sure all distributions have to ben uploaded before triggering the update-atom-shell script of Atom.
This commit is contained in:
parent
0286379706
commit
c2093946c8
1 changed files with 25 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import argparse
|
||||||
import errno
|
import errno
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
|
@ -17,17 +18,32 @@ TARGET_PLATFORM = {
|
||||||
'win32': 'win32',
|
'win32': 'win32',
|
||||||
}[sys.platform]
|
}[sys.platform]
|
||||||
|
|
||||||
|
ATOM_SHELL_VRESION = get_atom_shell_version()
|
||||||
|
|
||||||
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||||
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
|
||||||
DIST_NAME = 'atom-shell-{0}-{1}.zip'.format(get_atom_shell_version(),
|
DIST_NAME = 'atom-shell-{0}-{1}.zip'.format(ATOM_SHELL_VRESION, TARGET_PLATFORM)
|
||||||
TARGET_PLATFORM)
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
args = parse_args()
|
||||||
|
|
||||||
if not dist_newer_than_head():
|
if not dist_newer_than_head():
|
||||||
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])
|
||||||
upload()
|
|
||||||
|
bucket, access_key, secret_key = s3_config()
|
||||||
|
upload(bucket, access_key, secret_key)
|
||||||
|
if not args.no_update_version:
|
||||||
|
update_version(bucket, access_key, secret_key)
|
||||||
|
|
||||||
|
|
||||||
|
def parse_args():
|
||||||
|
parser = argparse.ArgumentParser(description='upload distribution file')
|
||||||
|
parser.add_argument('-n', '--no-update-version',
|
||||||
|
help='Do not update the latest version file',
|
||||||
|
action='store_false')
|
||||||
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def dist_newer_than_head():
|
def dist_newer_than_head():
|
||||||
|
@ -44,17 +60,19 @@ def dist_newer_than_head():
|
||||||
return dist_time > int(head_time)
|
return dist_time > int(head_time)
|
||||||
|
|
||||||
|
|
||||||
def upload():
|
def upload(bucket, access_key, secret_key, version=ATOM_SHELL_VRESION):
|
||||||
os.chdir(DIST_DIR)
|
os.chdir(DIST_DIR)
|
||||||
bucket, access_key, secret_key = s3_config()
|
|
||||||
|
|
||||||
version = get_atom_shell_version()
|
|
||||||
s3put(bucket, access_key, secret_key, DIST_DIR,
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
||||||
'atom-shell/{0}'.format(version), [DIST_NAME])
|
'atom-shell/{0}'.format(version), [DIST_NAME])
|
||||||
s3put(bucket, access_key, secret_key, DIST_DIR,
|
s3put(bucket, access_key, secret_key, DIST_DIR,
|
||||||
'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
|
'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
|
||||||
|
|
||||||
update_version(bucket, access_key, secret_key)
|
|
||||||
|
def update_version(bucket, access_key, secret_key):
|
||||||
|
prefix = os.path.join(SOURCE_ROOT, 'dist')
|
||||||
|
version = os.path.join(prefix, 'version')
|
||||||
|
s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [version])
|
||||||
|
|
||||||
|
|
||||||
def s3_config():
|
def s3_config():
|
||||||
|
@ -68,12 +86,6 @@ def s3_config():
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
|
||||||
def update_version(bucket, access_key, secret_key):
|
|
||||||
prefix = os.path.join(SOURCE_ROOT, 'dist')
|
|
||||||
version = os.path.join(prefix, 'version')
|
|
||||||
s3put(bucket, access_key, secret_key, prefix, 'atom-shell', [ version ])
|
|
||||||
|
|
||||||
|
|
||||||
def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
def s3put(bucket, access_key, secret_key, prefix, key_prefix, files):
|
||||||
args = [
|
args = [
|
||||||
's3put',
|
's3put',
|
||||||
|
|
Loading…
Reference in a new issue