]> khamidou — GitHub mirrors - electron.git/commitdiff
Move the code of uploading node headers to the new script
authorCheng Zhao <zcbenz@gmail.com>
Fri, 23 Jan 2015 01:18:31 +0000 (17:18 -0800)
committerCheng Zhao <zcbenz@gmail.com>
Tue, 27 Jan 2015 21:19:18 +0000 (13:19 -0800)
script/upload-node-headers.py
script/upload.py

index 408a85c64a04e5771dc283fa59744d9dcf8a11da..7b5ad135c9a2390470dcc3a0d967a3685dfb043f 100755 (executable)
@@ -1,17 +1,20 @@
 #!/usr/bin/env python
 
 import argparse
+import glob
 import os
 import shutil
 import sys
 import tarfile
 
-from lib.util import safe_mkdir, scoped_cwd
+from lib.config import TARGET_PLATFORM
+from lib.util import execute, safe_mkdir, scoped_cwd, s3_config, s3put
 
 
 SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
-DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
-NODE_DIR = os.path.join(SOURCE_ROOT, 'vendor', 'node')
+DIST_DIR    = os.path.join(SOURCE_ROOT, 'dist')
+NODE_DIR    = os.path.join(SOURCE_ROOT, 'vendor', 'node')
+OUT_DIR     = os.path.join(SOURCE_ROOT, 'out', 'Release')
 
 HEADERS_SUFFIX = [
   '.h',
@@ -36,9 +39,19 @@ def main():
 
   args = parse_args()
   dist_headers_dir = os.path.join(DIST_DIR, 'node-{0}'.format(args.version))
+
   copy_headers(dist_headers_dir)
   create_header_tarball(dist_headers_dir)
 
+  # Upload node's headers to S3.
+  bucket, access_key, secret_key = s3_config()
+  upload_node(bucket, access_key, secret_key, args.version)
+
+  # Upload the SHASUMS.txt.
+  execute([sys.executable,
+           os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
+           '-v', args.version])
+
 
 def parse_args():
   parser = argparse.ArgumentParser(description='upload sumsha file')
@@ -91,5 +104,44 @@ def copy_source_file(source, start, destination):
   shutil.copy2(source, final_destination)
 
 
+def upload_node(bucket, access_key, secret_key, version):
+  os.chdir(DIST_DIR)
+
+  s3put(bucket, access_key, secret_key, DIST_DIR,
+        'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
+
+  if TARGET_PLATFORM == 'win32':
+    # Generate the node.lib.
+    build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
+    execute([sys.executable, build, '-c', 'Release', '-t', 'generate_node_lib'])
+
+    # Upload the 32bit node.lib.
+    node_lib = os.path.join(OUT_DIR, 'node.lib')
+    s3put(bucket, access_key, secret_key, OUT_DIR,
+          'atom-shell/dist/{0}'.format(version), [node_lib])
+
+    # Upload the fake 64bit node.lib.
+    touch_x64_node_lib()
+    node_lib = os.path.join(OUT_DIR, 'x64', 'node.lib')
+    s3put(bucket, access_key, secret_key, OUT_DIR,
+          'atom-shell/dist/{0}'.format(version), [node_lib])
+
+    # Upload the index.json
+    atom_shell = os.path.join(OUT_DIR, 'atom.exe')
+    index_json = os.path.join(OUT_DIR, 'index.json')
+    execute([atom_shell,
+             os.path.join(SOURCE_ROOT, 'script', 'dump-version-info.js'),
+             index_json])
+    s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',
+          [index_json])
+
+
+def touch_x64_node_lib():
+  x64_dir = os.path.join(OUT_DIR, 'x64')
+  safe_mkdir(x64_dir)
+  with open(os.path.join(x64_dir, 'node.lib'), 'w+') as node_lib:
+    node_lib.write('Invalid library')
+
+
 if __name__ == '__main__':
   sys.exit(main())
index 320bd0661a2533249c0e2a4dbf272320d028d2a0..5954c5515af940ac077cb83dfb1a3379858b6e46 100755 (executable)
@@ -10,8 +10,7 @@ import tempfile
 
 from lib.config import DIST_ARCH, TARGET_PLATFORM
 from lib.util import execute, get_atom_shell_version, parse_version, \
-                     get_chromedriver_version, scoped_cwd, safe_mkdir, \
-                     s3_config, s3put
+                     get_chromedriver_version, scoped_cwd
 from lib.github import GitHub
 
 
@@ -60,15 +59,6 @@ def main():
                       os.path.join(DIST_DIR, CHROMEDRIVER_NAME))
 
   if args.publish_release:
-    # Upload node's headers to S3.
-    bucket, access_key, secret_key = s3_config()
-    upload_node(bucket, access_key, secret_key, ATOM_SHELL_VERSION)
-
-    # Upload the SHASUMS.txt.
-    execute([sys.executable,
-             os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
-             '-v', ATOM_SHELL_VERSION])
-
     # Upload PDBs to Windows symbol server.
     if TARGET_PLATFORM == 'win32':
       execute([sys.executable,
@@ -168,38 +158,6 @@ def publish_release(github, release_id):
   github.repos(ATOM_SHELL_REPO).releases(release_id).patch(data=data)
 
 
-def upload_node(bucket, access_key, secret_key, version):
-  os.chdir(DIST_DIR)
-
-  s3put(bucket, access_key, secret_key, DIST_DIR,
-        'atom-shell/dist/{0}'.format(version), glob.glob('node-*.tar.gz'))
-
-  if TARGET_PLATFORM == 'win32':
-    # Generate the node.lib.
-    build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
-    execute([sys.executable, build, '-c', 'Release', '-t', 'generate_node_lib'])
-
-    # Upload the 32bit node.lib.
-    node_lib = os.path.join(OUT_DIR, 'node.lib')
-    s3put(bucket, access_key, secret_key, OUT_DIR,
-          'atom-shell/dist/{0}'.format(version), [node_lib])
-
-    # Upload the fake 64bit node.lib.
-    touch_x64_node_lib()
-    node_lib = os.path.join(OUT_DIR, 'x64', 'node.lib')
-    s3put(bucket, access_key, secret_key, OUT_DIR,
-          'atom-shell/dist/{0}'.format(version), [node_lib])
-
-    # Upload the index.json
-    atom_shell = os.path.join(OUT_DIR, 'atom.exe')
-    index_json = os.path.join(OUT_DIR, 'index.json')
-    execute([atom_shell,
-             os.path.join(SOURCE_ROOT, 'script', 'dump-version-info.js'),
-             index_json])
-    s3put(bucket, access_key, secret_key, OUT_DIR, 'atom-shell/dist',
-          [index_json])
-
-
 def auth_token():
   token = os.environ.get('ATOM_SHELL_GITHUB_TOKEN')
   message = ('Error: Please set the $ATOM_SHELL_GITHUB_TOKEN '
@@ -208,13 +166,6 @@ def auth_token():
   return token
 
 
-def touch_x64_node_lib():
-  x64_dir = os.path.join(OUT_DIR, 'x64')
-  safe_mkdir(x64_dir)
-  with open(os.path.join(x64_dir, 'node.lib'), 'w+') as node_lib:
-    node_lib.write('Invalid library')
-
-
 if __name__ == '__main__':
   import sys
   sys.exit(main())