]> khamidou — GitHub mirrors - electron.git/commitdiff
Add script to make distribution and upload.
authorCheng Zhao <zcbenz@gmail.com>
Sun, 12 May 2013 08:16:02 +0000 (16:16 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sun, 12 May 2013 08:16:02 +0000 (16:16 +0800)
The scripts are stolen from aroben/libchromiumcontent.

.gitignore
script/create-dist [new file with mode: 0755]
script/upload [new file with mode: 0755]

index dd342440b8e3d0838cf9f6e2d0e6730b94f9d695..9b26df2c96cc088b9d9f674aba49a22152546be1 100644 (file)
@@ -1,5 +1,7 @@
 .DS_Store
+atom-shell.zip
 build/
+dist/
 node/
 node_modules/
 vendor/
diff --git a/script/create-dist b/script/create-dist
new file mode 100755 (executable)
index 0000000..74d5635
--- /dev/null
@@ -0,0 +1,52 @@
+#!/usr/bin/env python
+
+import errno
+import os
+import shutil
+
+
+SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+DIST_DIR = os.path.join(SOURCE_ROOT, 'dist')
+BUNDLE_NAME = 'Atom.app'
+BUNDLE_DIR = os.path.join(SOURCE_ROOT, 'build', 'Release', BUNDLE_NAME)
+
+
+def main():
+    rm_rf(DIST_DIR)
+    os.makedirs(DIST_DIR)
+
+    copy_binaries()
+    create_zip()
+
+
+def copy_binaries():
+    shutil.copytree(BUNDLE_DIR, os.path.join(DIST_DIR, BUNDLE_NAME))
+
+
+def create_zip():
+    print "Zipping distribution..."
+    zip_file = os.path.join(SOURCE_ROOT, 'atom-shell.zip')
+    safe_unlink(zip_file)
+    shutil.make_archive(os.path.splitext(zip_file)[0], 'zip',
+                        root_dir=DIST_DIR)
+
+
+def rm_rf(path):
+    try:
+        shutil.rmtree(path)
+    except OSError as e:
+        if e.errno != errno.ENOENT:
+            raise
+
+
+def safe_unlink(path):
+    try:
+        os.unlink(path)
+    except OSError as e:
+        if e.errno != errno.ENOENT:
+            raise
+
+
+if __name__ == '__main__':
+    import sys
+    sys.exit(main())
diff --git a/script/upload b/script/upload
new file mode 100755 (executable)
index 0000000..e0387b5
--- /dev/null
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+
+import errno
+import glob
+import os
+import subprocess
+
+
+SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
+
+
+def main():
+    try:
+        ensure_s3put()
+        upload()
+    except AssertionError as e:
+        return e.message
+
+
+def ensure_s3put():
+    output = ''
+    try:
+        output = subprocess.check_output(['s3put', '--help'])
+    except OSError as e:
+        if e.errno != errno.ENOENT:
+            raise
+    assert 'multipart' in output, 'Error: Please install boto and filechunkio'
+
+
+def upload():
+    os.chdir(SOURCE_ROOT)
+    bucket, access_key, secret_key = s3_config()
+    commit = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip()
+
+    args = [
+        's3put',
+        '--bucket', bucket,
+        '--access_key', access_key,
+        '--secret_key', secret_key,
+        '--prefix', SOURCE_ROOT,
+        '--key_prefix', 'atom-shell/{0}'.format(commit),
+        '--grant', 'public-read'
+    ] + glob.glob('atom-shell*.zip')
+
+    subprocess.check_call(args)
+
+
+def s3_config():
+    config = (os.environ.get('ATOM_SHELL_S3_BUCKET', ''),
+              os.environ.get('ATOM_SHELL_S3_ACCESS_KEY', ''),
+              os.environ.get('ATOM_SHELL_S3_SECRET_KEY', ''))
+    message = ('Error: Please set the $ATOM_SHELL_S3_BUCKET, '
+               '$ATOM_SHELL_S3_ACCESS_KEY, and '
+               '$ATOM_SHELL_S3_SECRET_KEY environment variables')
+    assert all(len(c) for c in config), message
+    return config
+
+
+if __name__ == '__main__':
+    import sys
+    sys.exit(main())