diff --git a/script/archive.py b/script/archive.py index e139f5d..2cc0b5e 100755 --- a/script/archive.py +++ b/script/archive.py @@ -73,6 +73,8 @@ def main(): dist = 'Skia-' + version + '-' + target + '-' + build_type + '-' + machine + classifier + '.zip' print('> Writing', dist) + + base = 'Skia-' + common.version() + '-' + common.target() + '-' + common.build_type() + '-' + common.machine() + common.classifier() with zipfile.ZipFile(os.path.join(os.pardir, dist), 'w', compression=zipfile.ZIP_DEFLATED) as zip: dirs = set() @@ -84,8 +86,8 @@ def main(): zip.write(str(dir)) dirs.add(dir) zip.write(str(path)) - zip.write(os.path.join(os.pardir, "depot_tools.zip")) - zip.write(os.path.join(os.pardir, "skia.zip")) + zip.write(os.path.join(os.pardir, base + "-depot_tools.zip")) + zip.write(os.path.join(os.pardir, base + "-skia.zip")) return 0 diff --git a/script/checkout.py b/script/checkout.py index e588b4b..120a397 100755 --- a/script/checkout.py +++ b/script/checkout.py @@ -58,9 +58,11 @@ def main(): else: subprocess.check_call(["python", "tools/git-sync-deps"]) + print("> Compressing source code") os.chdir(rootPath) - shutil.make_archive("depot_tools", "zip", "depot_tools") - shutil.make_archive("skia", "zip", "skia") + base = 'Skia-' + common.version() + '-' + common.target() + '-' + common.build_type() + '-' + common.machine() + common.classifier() + shutil.make_archive(base + "-depot_tools", "zip", "depot_tools") + shutil.make_archive(base + "-skia", "zip", "skia") return 0 diff --git a/script/release.py b/script/release.py index cd905da..be302c6 100755 --- a/script/release.py +++ b/script/release.py @@ -16,22 +16,35 @@ def main(): print('Can\'t find "' + zip + '"') return 1 - headers = common.github_headers() - try: - resp = urllib.request.urlopen(urllib.request.Request('https://api.github.com/repos/Bob-the-Git/skia-pack/releases/tags/' + version, headers=headers)).read() - except urllib.error.URLError as e: - data = '{"tag_name":"' + version + '","name":"' + version + '"}' - resp = urllib.request.urlopen(urllib.request.Request('https://api.github.com/repos/Bob-the-Git/skia-pack/releases', data=data.encode('utf-8'), headers=headers)).read() - upload_url = re.match('https://.*/assets', json.loads(resp.decode('utf-8'))['upload_url']).group(0) - - print('Uploading', zip, 'to', upload_url) - headers['Content-Type'] = 'application/zip' - headers['Content-Length'] = os.path.getsize(zip) - with open(zip, 'rb') as data: - urllib.request.urlopen(urllib.request.Request(upload_url + '?name=' + zip, data=data, headers=headers)) + CHUNK_SIZE = 1024 * 1024 * 1024 + file_number = 1 + with open(zip) as f: + chunk = f.read(CHUNK_SIZE) + while chunk: + with open(zip + "." + str(file_number)) as chunk_file: + chunk_file.write(chunk) + upload(zip + "." + str(file_number)) + file_number += 1 + chunk = f.read(CHUNK_SIZE) return 0 +def upload(zip): + headers = common.github_headers() + + try: + resp = urllib.request.urlopen(urllib.request.Request('https://api.github.com/repos/Bob-the-Git/skia-pack/releases/tags/' + common.version(), headers=headers)).read() + except urllib.error.URLError as e: + data = '{"tag_name":"' + common.version() + '","name":"' + common.version() + '"}' + resp = urllib.request.urlopen(urllib.request.Request('https://api.github.com/repos/Bob-the-Git/skia-pack/releases', data=data.encode('utf-8'), headers=headers)).read() + upload_url = re.match('https://.*/assets', json.loads(resp.decode('utf-8'))['upload_url']).group(0) + + print('Uploading', zip, 'to', upload_url) + headers['Content-Type'] = 'application/zip' + headers['Content-Length'] = os.path.getsize(zip) + with open(zip, 'rb') as data: + urllib.request.urlopen(urllib.request.Request(upload_url + '?name=' + zip, data=data, headers=headers)) + if __name__ == '__main__': sys.exit(main())