From 8e5a4345607c9d2d58fb3d1dfa044417ad45d368 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 11:40:20 +0800 Subject: [PATCH 01/22] Suppress window operations in CI --- spec/api-browser-window-spec.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/api-browser-window-spec.coffee b/spec/api-browser-window-spec.coffee index 390f29bf2f0..e7406f9a2af 100644 --- a/spec/api-browser-window-spec.coffee +++ b/spec/api-browser-window-spec.coffee @@ -206,7 +206,7 @@ describe 'browser-window module', -> w.loadUrl "file://#{fixtures}/pages/target-name.html" describe 'maximize event', -> - return if isCI and process.platform is 'linux' + return if isCI it 'emits when window is maximized', (done) -> @timeout 10000 w.once 'maximize', -> done() @@ -214,7 +214,7 @@ describe 'browser-window module', -> w.maximize() describe 'unmaximize event', -> - return if isCI and process.platform is 'linux' + return if isCI it 'emits when window is unmaximized', (done) -> @timeout 10000 w.once 'unmaximize', -> done() @@ -223,7 +223,7 @@ describe 'browser-window module', -> w.unmaximize() describe 'minimize event', -> - return if isCI and process.platform is 'linux' + return if isCI it 'emits when window is minimized', (done) -> @timeout 10000 w.once 'minimize', -> done() From 83ee7a464d62810c950c872031a5bb43f539900a Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 11:59:34 +0800 Subject: [PATCH 02/22] Avoid using the old gyp lib in system --- script/update.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/update.py b/script/update.py index 2cbfa706e6e..8c6283d1967 100755 --- a/script/update.py +++ b/script/update.py @@ -51,6 +51,10 @@ def run_gyp(target_arch, component): # Force using win32 python on cygwin. python = os.path.join('vendor', 'python_26', 'python.exe') gyp = os.path.join('vendor', 'brightray', 'vendor', 'gyp', 'gyp_main.py') + gyp_pylib = os.path.join(os.path.dirname(gyp), 'pylib') + # Avoid using the old gyp lib in system. + env['PYTHONPATH'] = os.path.pathsep.join([gyp_pylib, + env.get('PYTHONPATH', '')]) defines = [ '-Dlibchromiumcontent_component={0}'.format(component), '-Dtarget_arch={0}'.format(target_arch), From a720e52568db52fab43777e77803b31f71a9f5ee Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 12:04:27 +0800 Subject: [PATCH 03/22] Set DISPLAY in CI machine --- script/cibuild | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 1d03314f777..a23ce30ef89 100755 --- a/script/cibuild +++ b/script/cibuild @@ -43,9 +43,11 @@ def main(): deps += LINUX_DEPS_ARM execute(['sudo', 'apt-get', 'install'] + deps) - os.environ['DISPLAY'] = ':99.0' execute(['sh', '-e', '/etc/init.d/xvfb', 'start']) + if PLATFORM == 'linux': + os.environ['DISPLAY'] = ':99.0' + rm_rf(os.path.join(SOURCE_ROOT, 'out')) rm_rf(os.path.join(SOURCE_ROOT, 'frameworks')) rm_rf(os.path.join(SOURCE_ROOT, 'external_binaries')) From f99cd4d05a2078d290c7cace311ab72aaa4dc362 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 12:08:14 +0800 Subject: [PATCH 04/22] Try doing release in CI --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index a23ce30ef89..6e492ea33fe 100755 --- a/script/cibuild +++ b/script/cibuild @@ -59,7 +59,7 @@ def main(): npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' execute([npm, 'install', 'npm@2.12.1']) - is_release = os.environ.has_key('ELECTRON_RELEASE') + is_release = not is_travis args = ['--target_arch=' + target_arch] if not is_release: args += ['--dev'] From 82153eb75f00f2ce9d6172abf3158435b67ae524 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:43:20 +0800 Subject: [PATCH 05/22] Upload dist to Releases --- script/cibuild | 1 + script/upload.py | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/script/cibuild b/script/cibuild index 6e492ea33fe..297e9fd1abb 100755 --- a/script/cibuild +++ b/script/cibuild @@ -72,6 +72,7 @@ def main(): if is_release: run_script('build.py', ['-c', 'R']) run_script('create-dist.py') + run_script('upload.py') elif PLATFORM == 'win32' or target_arch == 'x64': run_script('build.py', ['-c', 'D']) if PLATFORM != 'win32': diff --git a/script/upload.py b/script/upload.py index 466b0dd88ec..6af224704b2 100755 --- a/script/upload.py +++ b/script/upload.py @@ -51,7 +51,15 @@ def main(): return 1 github = GitHub(auth_token()) - release_id = create_or_get_release_draft(github, args.version) + releases = github.repos(ATOM_SHELL_REPO).releases.get() + tag_exists = False + for release in releases: + if release['tag_name'] == args.version: + tag_exists = True + break + + release_id = create_or_get_release_draft(github, releases, args.version, + tag_exists) if args.publish_release: # Upload the SHASUMS.txt. @@ -82,11 +90,11 @@ def main(): upload_atom_shell(github, release_id, os.path.join(DIST_DIR, MKSNAPSHOT_NAME)) - if PLATFORM == 'win32': + if PLATFORM == 'win32' and not tag_exists: # Upload node headers. execute([sys.executable, os.path.join(SOURCE_ROOT, 'script', 'upload-node-headers.py'), - '-v', ATOM_SHELL_VERSION]) + '-v', args.version]) def parse_args(): @@ -145,20 +153,24 @@ def get_text_with_editor(name): os.unlink(t.name) return text -def create_or_get_release_draft(github, tag): +def create_or_get_release_draft(github, releases, tag, tag_exists): name = '{0} {1}'.format(PROJECT_NAME, tag) - releases = github.repos(ATOM_SHELL_REPO).releases.get() + # Search for existing draft. for release in releases: - # The untagged commit doesn't have a matching tag_name, so also check name. - if release['tag_name'] == tag or release['name'] == name: + if release['draft']: return release['id'] + if tag_exists: + tag += '-do-not-publish-me' return create_release_draft(github, tag) def create_release_draft(github, tag): name = '{0} {1}'.format(PROJECT_NAME, tag) - body = get_text_with_editor(name) + if os.environ.has_key('CI'): + body = '(placeholder)' + else: + body = get_text_with_editor(name) if body == '': sys.stderr.write('Quit due to empty release note.\n') sys.exit(0) From 1212e45a6eece3536f4081437eaa6195ea4cdde1 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:45:29 +0800 Subject: [PATCH 06/22] Fix pylint warning --- script/upload.py | 1 - 1 file changed, 1 deletion(-) diff --git a/script/upload.py b/script/upload.py index 6af224704b2..12c31c703c6 100755 --- a/script/upload.py +++ b/script/upload.py @@ -154,7 +154,6 @@ def get_text_with_editor(name): return text def create_or_get_release_draft(github, releases, tag, tag_exists): - name = '{0} {1}'.format(PROJECT_NAME, tag) # Search for existing draft. for release in releases: if release['draft']: From e4530e6e328b343d7bb704cd7daa10a5ec2e9c86 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:46:26 +0800 Subject: [PATCH 07/22] Don't force redownloading some assets --- script/cibuild | 5 ----- 1 file changed, 5 deletions(-) diff --git a/script/cibuild b/script/cibuild index 297e9fd1abb..e5a5366b7aa 100755 --- a/script/cibuild +++ b/script/cibuild @@ -49,11 +49,6 @@ def main(): os.environ['DISPLAY'] = ':99.0' rm_rf(os.path.join(SOURCE_ROOT, 'out')) - rm_rf(os.path.join(SOURCE_ROOT, 'frameworks')) - rm_rf(os.path.join(SOURCE_ROOT, 'external_binaries')) - rm_rf(os.path.join(SOURCE_ROOT, 'vendor', 'apm', 'node_modules')) - rm_rf(os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download', - 'libchromiumcontent')) # CI's npm is not reliable. npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' From 6b7d3a070ae3a45138384711bd1026b3c90233f9 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:52:13 +0800 Subject: [PATCH 08/22] Clean before and after cibuild Our CI machine is out of disk space --- script/cibuild | 7 +++++-- script/clean.py | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index e5a5366b7aa..8f5185da714 100755 --- a/script/cibuild +++ b/script/cibuild @@ -48,7 +48,7 @@ def main(): if PLATFORM == 'linux': os.environ['DISPLAY'] = ':99.0' - rm_rf(os.path.join(SOURCE_ROOT, 'out')) + execute(['clean.py']) # CI's npm is not reliable. npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' @@ -81,4 +81,7 @@ def run_script(script, args=[]): if __name__ == '__main__': - sys.exit(main()) + try: + sys.exit(main()) + except subprocess.CalledProcessError: + execute(['clean.py']) diff --git a/script/clean.py b/script/clean.py index f27ee9cbea3..cd72230a371 100755 --- a/script/clean.py +++ b/script/clean.py @@ -12,8 +12,10 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def main(): os.chdir(SOURCE_ROOT) rm_rf('node_modules') + rm_rf('dist') rm_rf('out') rm_rf('spec/node_modules') + rm_rf('vendor/brightray/vendor/download/libchromiumcontent') if __name__ == '__main__': From f5ae3111bae2585566983df0fab61c1589678e61 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:54:29 +0800 Subject: [PATCH 09/22] Fix calling clean.py --- script/cibuild | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/cibuild b/script/cibuild index 8f5185da714..cbd3c75d0df 100755 --- a/script/cibuild +++ b/script/cibuild @@ -48,7 +48,7 @@ def main(): if PLATFORM == 'linux': os.environ['DISPLAY'] = ':99.0' - execute(['clean.py']) + run_script('clean.py') # CI's npm is not reliable. npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' @@ -84,4 +84,5 @@ if __name__ == '__main__': try: sys.exit(main()) except subprocess.CalledProcessError: - execute(['clean.py']) + run_script('clean.py') + raise From e95ee4775e2063602b05927e2f8ca28d7fc4b8ba Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 13:59:02 +0800 Subject: [PATCH 10/22] Ignore Windows errors in clean.py --- script/clean.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/script/clean.py b/script/clean.py index cd72230a371..094f70df7a2 100755 --- a/script/clean.py +++ b/script/clean.py @@ -11,11 +11,14 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def main(): os.chdir(SOURCE_ROOT) - rm_rf('node_modules') - rm_rf('dist') - rm_rf('out') - rm_rf('spec/node_modules') - rm_rf('vendor/brightray/vendor/download/libchromiumcontent') + try: + rm_rf('node_modules') + rm_rf('dist') + rm_rf('out') + rm_rf('spec/node_modules') + rm_rf('vendor/brightray/vendor/download/libchromiumcontent') + except WindowsError: # pylint: disable=E0602 + pass if __name__ == '__main__': From 89b22db618b6894ed08f5b4cd1b8d8a9806eb83e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:23:42 +0800 Subject: [PATCH 11/22] Build the python requests library --- .gitmodules | 3 +++ script/bootstrap.py | 8 +++++++- script/lib/github.py | 6 ++++++ vendor/requests | 1 + 4 files changed, 17 insertions(+), 1 deletion(-) create mode 160000 vendor/requests diff --git a/.gitmodules b/.gitmodules index 7c26c6c2c12..5517d4434f3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,3 +16,6 @@ [submodule "vendor/crashpad"] path = vendor/crashpad url = https://github.com/atom/crashpad.git +[submodule "vendor/requests"] + path = vendor/requests + url = https://github.com/kennethreitz/requests diff --git a/script/bootstrap.py b/script/bootstrap.py index fd9958d9ca1..94a566224c3 100755 --- a/script/bootstrap.py +++ b/script/bootstrap.py @@ -37,6 +37,7 @@ def main(): update_clang() update_submodules() + setup_requests() update_node_modules('.') bootstrap_brightray(args.dev, args.url, args.target_arch) @@ -84,6 +85,11 @@ def update_submodules(): execute_stdout(['git', 'submodule', 'update', '--init', '--recursive']) +def setup_requests(): + with scoped_cwd(os.path.join(VENDOR_DIR, 'requests')): + execute_stdout([sys.executable, 'setup.py', 'build']) + + def bootstrap_brightray(is_dev, url, target_arch): bootstrap = os.path.join(VENDOR_DIR, 'brightray', 'script', 'bootstrap') args = [ @@ -109,7 +115,7 @@ def update_node_modules(dirname, env=None): with scoped_cwd(dirname): args = [NPM, 'install'] if is_verbose_mode(): - args += '--verbose' + args += ['--verbose'] # Ignore npm install errors when running in CI. if os.environ.has_key('CI'): try: diff --git a/script/lib/github.py b/script/lib/github.py index a742a209c16..5e968d6698b 100644 --- a/script/lib/github.py +++ b/script/lib/github.py @@ -1,7 +1,13 @@ #!/usr/bin/env python import json +import os import re +import sys + +sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..', + 'vendor', 'requests', 'build', + 'lib'))) import requests GITHUB_URL = 'https://api.github.com' diff --git a/vendor/requests b/vendor/requests new file mode 160000 index 00000000000..e4d59bedfd3 --- /dev/null +++ b/vendor/requests @@ -0,0 +1 @@ +Subproject commit e4d59bedfd3c7f4f254f4f5d036587bcd8152458 From 20e9abe26a0992df38180b786aa60dd4888c8dba Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:30:59 +0800 Subject: [PATCH 12/22] Don't check build version in CI --- script/upload.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/upload.py b/script/upload.py index 12c31c703c6..b4fc96ec4c9 100755 --- a/script/upload.py +++ b/script/upload.py @@ -108,6 +108,9 @@ def parse_args(): def get_atom_shell_build_version(): + if os.environ.has_key('CI'): + # In CI we just build as told. + return ATOM_SHELL_VERSION if PLATFORM == 'darwin': atom_shell = os.path.join(SOURCE_ROOT, 'out', 'R', '{0}.app'.format(PRODUCT_NAME), 'Contents', From b30709f1332bdfe7893e3df933c225027c2edb47 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:36:45 +0800 Subject: [PATCH 13/22] No need to clean after cibuild --- script/cibuild | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/script/cibuild b/script/cibuild index cbd3c75d0df..9c875581ac3 100755 --- a/script/cibuild +++ b/script/cibuild @@ -81,8 +81,4 @@ def run_script(script, args=[]): if __name__ == '__main__': - try: - sys.exit(main()) - except subprocess.CalledProcessError: - run_script('clean.py') - raise + sys.exit(main()) From f87a4b9a04729e9100c914855f4d2665ac00ee46 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:40:32 +0800 Subject: [PATCH 14/22] One failing rm should not block others --- script/clean.py | 13 +++++-------- script/lib/util.py | 2 ++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/script/clean.py b/script/clean.py index 094f70df7a2..cd72230a371 100755 --- a/script/clean.py +++ b/script/clean.py @@ -11,14 +11,11 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) def main(): os.chdir(SOURCE_ROOT) - try: - rm_rf('node_modules') - rm_rf('dist') - rm_rf('out') - rm_rf('spec/node_modules') - rm_rf('vendor/brightray/vendor/download/libchromiumcontent') - except WindowsError: # pylint: disable=E0602 - pass + rm_rf('node_modules') + rm_rf('dist') + rm_rf('out') + rm_rf('spec/node_modules') + rm_rf('vendor/brightray/vendor/download/libchromiumcontent') if __name__ == '__main__': diff --git a/script/lib/util.py b/script/lib/util.py index a995b605613..5e8933d0302 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -136,6 +136,8 @@ def rm_rf(path): except OSError as e: if e.errno != errno.ENOENT: raise + except WindowsError: # pylint: disable=E0602 + pass def safe_unlink(path): From 7288581393f672d04103aebebff6cbcaad5d4b28 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:43:58 +0800 Subject: [PATCH 15/22] Fix path to requests library --- script/lib/github.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/script/lib/github.py b/script/lib/github.py index 5e968d6698b..def7be585e8 100644 --- a/script/lib/github.py +++ b/script/lib/github.py @@ -5,9 +5,10 @@ import os import re import sys -sys.path.append(os.path.abspath(os.path.join(__file__, '..', '..', '..', - 'vendor', 'requests', 'build', - 'lib'))) +REQUESTS_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', + 'vendor', 'requests')) +sys.path.append(os.path.join(REQUESTS_DIR, 'build', 'lib')) +sys.path.append(os.path.join(REQUESTS_DIR, 'build', 'lib.linux-x86_64-2.7')) import requests GITHUB_URL = 'https://api.github.com' From 2717556a92a3d54969107c85fdbb2bc0acaab00e Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:46:26 +0800 Subject: [PATCH 16/22] WindowsError is a subclass of OSError --- script/lib/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/script/lib/util.py b/script/lib/util.py index 5e8933d0302..a79a40f7ebc 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -133,11 +133,11 @@ def make_zip(zip_file_path, files, dirs): def rm_rf(path): try: shutil.rmtree(path) + except WindowsError: # pylint: disable=E0602 + pass except OSError as e: if e.errno != errno.ENOENT: raise - except WindowsError: # pylint: disable=E0602 - pass def safe_unlink(path): From 12233d704be176b7ba1003ffbf7fe114d09f4537 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:49:29 +0800 Subject: [PATCH 17/22] Use better tag and title --- script/upload.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/upload.py b/script/upload.py index b4fc96ec4c9..707dcb5079a 100755 --- a/script/upload.py +++ b/script/upload.py @@ -163,15 +163,16 @@ def create_or_get_release_draft(github, releases, tag, tag_exists): return release['id'] if tag_exists: - tag += '-do-not-publish-me' + tag = 'do-not-publish-me' return create_release_draft(github, tag) def create_release_draft(github, tag): - name = '{0} {1}'.format(PROJECT_NAME, tag) if os.environ.has_key('CI'): + name = '{0} pending draft'.format(PROJECT_NAME) body = '(placeholder)' else: + name = '{0} {1}'.format(PROJECT_NAME, tag) body = get_text_with_editor(name) if body == '': sys.stderr.write('Quit due to empty release note.\n') From 518ec36511254bf78b0e64bf7a7044a1fff31069 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 14:54:32 +0800 Subject: [PATCH 18/22] WindowsError is undefined on POSIX --- script/lib/util.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/script/lib/util.py b/script/lib/util.py index a79a40f7ebc..109e7254017 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -133,10 +133,8 @@ def make_zip(zip_file_path, files, dirs): def rm_rf(path): try: shutil.rmtree(path) - except WindowsError: # pylint: disable=E0602 - pass except OSError as e: - if e.errno != errno.ENOENT: + if e.errno != errno.ENOENT and e.errno != errno.EIO: raise From 02f3d7a25e98bd716760693b60e04a5d1d57ae76 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 15:07:11 +0800 Subject: [PATCH 19/22] Just ignore all OSError for rm_rf --- script/lib/util.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/script/lib/util.py b/script/lib/util.py index 109e7254017..d7559ff7f71 100644 --- a/script/lib/util.py +++ b/script/lib/util.py @@ -133,9 +133,8 @@ def make_zip(zip_file_path, files, dirs): def rm_rf(path): try: shutil.rmtree(path) - except OSError as e: - if e.errno != errno.ENOENT and e.errno != errno.EIO: - raise + except OSError: + pass def safe_unlink(path): From ffb173260743477572f940e9f61a383ec4d9ac11 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 15:26:54 +0800 Subject: [PATCH 20/22] Delete the original file before uploading in CI --- script/upload.py | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/script/upload.py b/script/upload.py index 707dcb5079a..afd186a9600 100755 --- a/script/upload.py +++ b/script/upload.py @@ -58,8 +58,8 @@ def main(): tag_exists = True break - release_id = create_or_get_release_draft(github, releases, args.version, - tag_exists) + release = create_or_get_release_draft(github, releases, args.version, + tag_exists) if args.publish_release: # Upload the SHASUMS.txt. @@ -72,23 +72,21 @@ def main(): os.path.join(SOURCE_ROOT, 'script', 'upload-index-json.py')]) # Press the publish button. - publish_release(github, release_id) + publish_release(github, release['id']) # Do not upload other files when passed "-p". return # Upload atom-shell with GitHub Releases API. - upload_atom_shell(github, release_id, os.path.join(DIST_DIR, DIST_NAME)) - upload_atom_shell(github, release_id, os.path.join(DIST_DIR, SYMBOLS_NAME)) + upload_atom_shell(github, release, os.path.join(DIST_DIR, DIST_NAME)) + upload_atom_shell(github, release, os.path.join(DIST_DIR, SYMBOLS_NAME)) # Upload chromedriver and mksnapshot for minor version update. if get_target_arch() != 'arm' and parse_version(args.version)[2] == '0': chromedriver = 'chromedriver-{0}-{1}-{2}.zip'.format( get_chromedriver_version(), PLATFORM, get_target_arch()) - upload_atom_shell(github, release_id, - os.path.join(DIST_DIR, chromedriver)) - upload_atom_shell(github, release_id, - os.path.join(DIST_DIR, MKSNAPSHOT_NAME)) + upload_atom_shell(github, release, os.path.join(DIST_DIR, chromedriver)) + upload_atom_shell(github, release, os.path.join(DIST_DIR, MKSNAPSHOT_NAME)) if PLATFORM == 'win32' and not tag_exists: # Upload node headers. @@ -160,7 +158,7 @@ def create_or_get_release_draft(github, releases, tag, tag_exists): # Search for existing draft. for release in releases: if release['draft']: - return release['id'] + return release if tag_exists: tag = 'do-not-publish-me' @@ -180,14 +178,25 @@ def create_release_draft(github, tag): data = dict(tag_name=tag, name=name, body=body, draft=True) r = github.repos(ATOM_SHELL_REPO).releases.post(data=data) - return r['id'] + return r -def upload_atom_shell(github, release_id, file_path): +def upload_atom_shell(github, release, file_path): + # Delete the original file before uploading in CI. + if os.environ.has_key('CI'): + try: + for asset in release['assets']: + if asset['name'] == os.path.basename(file_path): + github.repos(ATOM_SHELL_REPO).releases.assets(asset['id']).delete() + break + except Exception: + pass + return + params = {'name': os.path.basename(file_path)} headers = {'Content-Type': 'application/zip'} with open(file_path, 'rb') as f: - github.repos(ATOM_SHELL_REPO).releases(release_id).assets.post( + github.repos(ATOM_SHELL_REPO).releases(release['id']).assets.post( params=params, headers=headers, data=f, verify=False) From bdbb994c7221167e6f0cfdd8f5df881df410bdbb Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 15:31:55 +0800 Subject: [PATCH 21/22] Fix pylint warning --- script/upload.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/upload.py b/script/upload.py index afd186a9600..3b622aa43d7 100755 --- a/script/upload.py +++ b/script/upload.py @@ -191,8 +191,8 @@ def upload_atom_shell(github, release, file_path): break except Exception: pass - return + # Upload the file. params = {'name': os.path.basename(file_path)} headers = {'Content-Type': 'application/zip'} with open(file_path, 'rb') as f: From 64c0e0dfdcd020b875f2cd3d61673a7ae2675729 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 3 Jul 2015 16:31:33 +0800 Subject: [PATCH 22/22] Only creates Release build when ELECTRON_RELEASE is set --- script/cibuild | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script/cibuild b/script/cibuild index 9c875581ac3..7236d9f7bbc 100755 --- a/script/cibuild +++ b/script/cibuild @@ -54,7 +54,7 @@ def main(): npm = 'npm.cmd' if PLATFORM == 'win32' else 'npm' execute([npm, 'install', 'npm@2.12.1']) - is_release = not is_travis + is_release = os.environ.has_key('ELECTRON_RELEASE') args = ['--target_arch=' + target_arch] if not is_release: args += ['--dev']