|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
import argparse
|
|
|
import errno
|
|
|
+from io import StringIO
|
|
|
import os
|
|
|
import subprocess
|
|
|
import sys
|
|
@@ -46,8 +47,7 @@ def main():
|
|
|
|
|
|
if not args.publish_release:
|
|
|
if not dist_newer_than_head():
|
|
|
- create_dist = os.path.join(SOURCE_ROOT, 'script', 'create-dist.py')
|
|
|
- execute([sys.executable, create_dist])
|
|
|
+ run_python_script('create-dist.py')
|
|
|
|
|
|
build_version = get_electron_build_version()
|
|
|
if not ELECTRON_VERSION.startswith(build_version):
|
|
@@ -69,14 +69,14 @@ def main():
|
|
|
tag_exists)
|
|
|
|
|
|
if args.publish_release:
|
|
|
- # Upload the SHASUMS.txt.
|
|
|
- execute([sys.executable,
|
|
|
- os.path.join(SOURCE_ROOT, 'script', 'upload-checksums.py'),
|
|
|
- '-v', ELECTRON_VERSION])
|
|
|
+ # Upload the Node SHASUMS*.txt.
|
|
|
+ run_python_script('upload-node-checksums.py', '-v', ELECTRON_VERSION)
|
|
|
|
|
|
# Upload the index.json.
|
|
|
- execute([sys.executable,
|
|
|
- os.path.join(SOURCE_ROOT, 'script', 'upload-index-json.py')])
|
|
|
+ run_python_script('upload-index-json.py')
|
|
|
+
|
|
|
+ # Create and upload the Electron SHASUMS*.txt
|
|
|
+ release_electron_checksums(github, release)
|
|
|
|
|
|
# Press the publish button.
|
|
|
publish_release(github, release['id'])
|
|
@@ -108,13 +108,10 @@ def main():
|
|
|
|
|
|
if PLATFORM == 'win32' and not tag_exists:
|
|
|
# Upload PDBs to Windows symbol server.
|
|
|
- execute([sys.executable,
|
|
|
- os.path.join(SOURCE_ROOT, 'script', 'upload-windows-pdb.py')])
|
|
|
+ run_python_script('upload-windows-pdb.py')
|
|
|
|
|
|
# Upload node headers.
|
|
|
- execute([sys.executable,
|
|
|
- os.path.join(SOURCE_ROOT, 'script', 'upload-node-headers.py'),
|
|
|
- '-v', args.version])
|
|
|
+ run_python_script('upload-node-headers.py', '-v', args.version)
|
|
|
|
|
|
|
|
|
def parse_args():
|
|
@@ -127,6 +124,11 @@ def parse_args():
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
+def run_python_script(script, *args):
|
|
|
+ script_path = os.path.join(SOURCE_ROOT, 'script', script),
|
|
|
+ return execute([sys.executable, script_path] + args)
|
|
|
+
|
|
|
+
|
|
|
def get_electron_build_version():
|
|
|
if get_target_arch() == 'arm' or os.environ.has_key('CI'):
|
|
|
# In CI we just build as told.
|
|
@@ -202,32 +204,35 @@ def create_release_draft(github, tag):
|
|
|
return r
|
|
|
|
|
|
|
|
|
+def release_electron_checksums(github, release):
|
|
|
+ checksums = run_python_script(
|
|
|
+ 'merge-electron-checksums.py', '-v', ELECTRON_VERSION)
|
|
|
+ upload_io_to_github(github, release,
|
|
|
+ 'SHASUMS256.txt', StringIO(checksums), 'text/plain')
|
|
|
+
|
|
|
+
|
|
|
def upload_electron(github, release, file_path):
|
|
|
- checksum_path = '{}.sha256sum'.format(file_path)
|
|
|
- # Delete the original file & its checksum before uploading in CI.
|
|
|
+ # Delete the original file before uploading in CI.
|
|
|
filename = os.path.basename(file_path)
|
|
|
- checksum_filename = os.path.basename(checksum_path)
|
|
|
if os.environ.has_key('CI'):
|
|
|
try:
|
|
|
for asset in release['assets']:
|
|
|
- if asset['name'] in [filename, checksum_filename]:
|
|
|
+ if asset['name'] == filename:
|
|
|
github.repos(ELECTRON_REPO).releases.assets(asset['id']).delete()
|
|
|
except Exception:
|
|
|
pass
|
|
|
|
|
|
# Upload the file.
|
|
|
- upload_asset_to_github(github, release, file_path, 'application/zip')
|
|
|
-
|
|
|
- # Upload the file's checksum.
|
|
|
- upload_asset_to_github(github, release, checksum_path, 'text/plain')
|
|
|
+ name = os.path.dirname(file_path)
|
|
|
+ with open(file_path, 'rb') as f:
|
|
|
+ upload_io_to_github(github, release, name, f, 'application/zip')
|
|
|
|
|
|
|
|
|
-def upload_asset_to_github(github, release, asset_path, content_type):
|
|
|
- params = {'name': os.path.dirname(asset_path)}
|
|
|
+def upload_io_to_github(github, release, name, io, content_type):
|
|
|
+ params = {'name': name}
|
|
|
headers = {'Content-Type': content_type}
|
|
|
- with open(asset_path) as f:
|
|
|
- github.repos(ELECTRON_REPO).releases(release['id']).assets.post(
|
|
|
- params=params, headers=headers, data=f, verify=False)
|
|
|
+ github.repos(ELECTRON_REPO).releases(release['id']).assets.post(
|
|
|
+ params=params, headers=headers, data=io, verify=False)
|
|
|
|
|
|
|
|
|
def publish_release(github, release_id):
|