blob: 183952c700875a9fe3b07da37520ca4c17d5cb5e [file] [log] [blame]
#!/usr/bin/env python
import argparse
import boto3
import os
import os.path
import sys
S3_BUCKET = 'archives.webkit.org'
S3_MINIFIED_BUCKET = 'minified-archives.webkit.org'
S3_REGION_PREFIX = 'https://s3-us-west-2.amazonaws.com'
def uploadToS3(archive_path, bucket, identifier, revision):
print 'Transferring {} to S3...'.format(archive_path)
key = '/'.join([identifier, revision + '.zip'])
print '\tS3 Bucket: {}\n\tS3 Key: {}'.format(bucket, key)
s3.upload_file(archive_path, bucket, key)
print('\tS3 URL: {}/{}/{}'.format(S3_REGION_PREFIX, bucket, key))
def archiveExists(archive):
if archive:
if os.path.exists(archive):
return True
else:
print 'WARNING: Archive does not exist: {}'.format(archive)
return False
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('--revision', action="store", required=True, help='Revision number for the built archive')
parser.add_argument('--identifier', action="store", required=True, help='S3 destination identifier, in the form of fullPlatform-architecture-configuration. [mac-sierra-x86_64-release]')
parser.add_argument('--archive', action="store", required=True, help='Path to the full size archive. [path/to/123456.zip]')
args = parser.parse_args()
head, tail = os.path.split(str(args.archive))
minifiedArchive = head + '/minified-' + tail
s3 = boto3.client('s3')
if archiveExists(args.archive):
uploadToS3(args.archive, S3_BUCKET, args.identifier, args.revision)
if archiveExists(minifiedArchive):
uploadToS3(minifiedArchive, S3_MINIFIED_BUCKET, args.identifier, args.revision)