Do not put the upload logic in make_zip
This commit is contained in:
parent
8f75f10239
commit
079a7a1a1c
3 changed files with 29 additions and 25 deletions
|
@ -3,7 +3,6 @@
|
||||||
import atexit
|
import atexit
|
||||||
import contextlib
|
import contextlib
|
||||||
import errno
|
import errno
|
||||||
import hashlib
|
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
@ -16,7 +15,7 @@ import urllib2
|
||||||
import os
|
import os
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
from config import is_verbose_mode, s3_config
|
from config import is_verbose_mode
|
||||||
from env_util import get_vs_env
|
from env_util import get_vs_env
|
||||||
|
|
||||||
BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor',
|
BOTO_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', 'vendor',
|
||||||
|
@ -133,22 +132,6 @@ def make_zip(zip_file_path, files, dirs):
|
||||||
for f in filenames:
|
for f in filenames:
|
||||||
zip_file.write(os.path.join(root, f))
|
zip_file.write(os.path.join(root, f))
|
||||||
zip_file.close()
|
zip_file.close()
|
||||||
upload_zip_sha256_checksum(zip_file_path)
|
|
||||||
|
|
||||||
|
|
||||||
def upload_zip_sha256_checksum(zip_file_path):
|
|
||||||
bucket, access_key, secret_key = s3_config()
|
|
||||||
checksum_path = '{}.sha256sum'.format(zip_file_path)
|
|
||||||
safe_unlink(checksum_path)
|
|
||||||
sha256 = hashlib.sha256()
|
|
||||||
with open(zip_file_path, 'rb') as f:
|
|
||||||
sha256.update(f.read())
|
|
||||||
|
|
||||||
zip_basename = os.path.basename(zip_file_path)
|
|
||||||
with open(checksum_path, 'w') as checksum:
|
|
||||||
checksum.write('{} *{}'.format(sha256.hexdigest(), zip_basename))
|
|
||||||
s3put(bucket, access_key, secret_key, os.path.dirname(checksum_path),
|
|
||||||
'atom-shell/tmp', [checksum_path])
|
|
||||||
|
|
||||||
|
|
||||||
def rm_rf(path):
|
def rm_rf(path):
|
||||||
|
|
11
script/merge-electron-checksums.py
Normal file → Executable file
11
script/merge-electron-checksums.py
Normal file → Executable file
|
@ -12,21 +12,23 @@ from lib.config import s3_config
|
||||||
from lib.util import boto_path_dirs
|
from lib.util import boto_path_dirs
|
||||||
|
|
||||||
sys.path.extend(boto_path_dirs())
|
sys.path.extend(boto_path_dirs())
|
||||||
|
|
||||||
from boto.s3.connection import S3Connection
|
from boto.s3.connection import S3Connection
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
bucket_name, access_key, secret_key = s3_config()
|
bucket_name, access_key, secret_key = s3_config()
|
||||||
s3 = S3Connection(access_key, secret_key)
|
s3 = S3Connection(access_key, secret_key)
|
||||||
bucket = s3.get_bucket(bucket_name)
|
bucket = s3.get_bucket(bucket_name)
|
||||||
if bucket is None:
|
if bucket is None:
|
||||||
print('S3 bucket "{}" does not exist!'.format(bucket_name), file=sys.stderr)
|
print('S3 bucket "{}" does not exist!'.format(bucket_name), file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
prefix = 'atom-shell/tmp/{0}/'.format(args.version)
|
||||||
shasums = [s3_object.get_contents_as_string().strip()
|
shasums = [s3_object.get_contents_as_string().strip()
|
||||||
for s3_object in bucket.list('atom-shell/tmp/', delimiter='/')
|
for s3_object in bucket.list(prefix, delimiter='/')
|
||||||
if s3_object.key.endswith('.sha256sum') and
|
if s3_object.key.endswith('.sha256sum')]
|
||||||
args.version in s3_object.key]
|
|
||||||
print('\n'.join(shasums))
|
print('\n'.join(shasums))
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -37,5 +39,6 @@ def parse_args():
|
||||||
required=True)
|
required=True)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
sys.exit(main())
|
sys.exit(main())
|
||||||
|
|
|
@ -2,16 +2,17 @@
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import errno
|
import errno
|
||||||
from io import StringIO
|
import hashlib
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
from io import StringIO
|
||||||
from lib.config import PLATFORM, get_target_arch, get_chromedriver_version, \
|
from lib.config import PLATFORM, get_target_arch, get_chromedriver_version, \
|
||||||
get_platform_key, get_env_var
|
get_platform_key, get_env_var, s3_config
|
||||||
from lib.util import electron_gyp, execute, get_electron_version, \
|
from lib.util import electron_gyp, execute, get_electron_version, \
|
||||||
parse_version, scoped_cwd
|
parse_version, scoped_cwd, s3put
|
||||||
from lib.github import GitHub
|
from lib.github import GitHub
|
||||||
|
|
||||||
|
|
||||||
|
@ -227,6 +228,9 @@ def upload_electron(github, release, file_path):
|
||||||
with open(file_path, 'rb') as f:
|
with open(file_path, 'rb') as f:
|
||||||
upload_io_to_github(github, release, name, f, 'application/zip')
|
upload_io_to_github(github, release, name, f, 'application/zip')
|
||||||
|
|
||||||
|
# Upload the checksum file.
|
||||||
|
upload_sha256_checksum(release['tag'], file_path)
|
||||||
|
|
||||||
|
|
||||||
def upload_io_to_github(github, release, name, io, content_type):
|
def upload_io_to_github(github, release, name, io, content_type):
|
||||||
params = {'name': name}
|
params = {'name': name}
|
||||||
|
@ -235,6 +239,20 @@ def upload_io_to_github(github, release, name, io, content_type):
|
||||||
params=params, headers=headers, data=io, verify=False)
|
params=params, headers=headers, data=io, verify=False)
|
||||||
|
|
||||||
|
|
||||||
|
def upload_sha256_checksum(version, file_path):
|
||||||
|
bucket, access_key, secret_key = s3_config()
|
||||||
|
checksum_path = '{}.sha256sum'.format(file_path)
|
||||||
|
sha256 = hashlib.sha256()
|
||||||
|
with open(file_path, 'rb') as f:
|
||||||
|
sha256.update(f.read())
|
||||||
|
|
||||||
|
filename = os.path.basename(file_path)
|
||||||
|
with open(checksum_path, 'w') as checksum:
|
||||||
|
checksum.write('{} *{}'.format(sha256.hexdigest(), filename))
|
||||||
|
s3put(bucket, access_key, secret_key, os.path.dirname(checksum_path),
|
||||||
|
'atom-shell/tmp/{0}'.format(version), [checksum_path])
|
||||||
|
|
||||||
|
|
||||||
def publish_release(github, release_id):
|
def publish_release(github, release_id):
|
||||||
data = dict(draft=False)
|
data = dict(draft=False)
|
||||||
github.repos(ELECTRON_REPO).releases(release_id).patch(data=data)
|
github.repos(ELECTRON_REPO).releases(release_id).patch(data=data)
|
||||||
|
|
Loading…
Reference in a new issue