Skip to content

Commit

Permalink
Split zip file; * 1
Browse files Browse the repository at this point in the history
  • Loading branch information
Bob-the-Git committed Sep 2, 2022
1 parent b383eca commit b771392
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 17 deletions.
6 changes: 4 additions & 2 deletions script/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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

Expand Down
6 changes: 4 additions & 2 deletions script/checkout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 26 additions & 13 deletions script/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit b771392

Please sign in to comment.