Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions build-support/download-release-artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# under the License.
#

import sys, json, urllib.request, os, shutil, zipfile, tempfile
import sys, requests, os, zipfile, tempfile
from pathlib import Path

if len(sys.argv) != 3:
Expand All @@ -39,33 +39,36 @@
dest_path = sys.argv[2]

workflow_run_url = LIST_URL % workflow_run_id
request = urllib.request.Request(workflow_run_url,
headers={'Accept': ACCEPT_HEADER, 'Authorization': 'Bearer ' + GITHUB_TOKEN})
with urllib.request.urlopen(request) as response:
data = json.loads(response.read().decode("utf-8"))
headers={'Accept': ACCEPT_HEADER, 'Authorization': 'Bearer ' + GITHUB_TOKEN}

with requests.get(workflow_run_url, headers=headers) as response:
response.raise_for_status()
data = response.json()
for artifact in data['artifacts']:
name = artifact['name']
# Skip debug artifact
if name.endswith("-Debug"):
continue
dest_dir = os.path.join(dest_path, name)
if name.find("windows") >= 0 and os.path.exists(dest_dir + ".tar.gz"):
print(f'Skip downloading {name} since {dest_dir}.tar.gz exists')
continue
if os.path.exists(dest_dir) and \
(os.path.isfile(dest_dir) or len(os.listdir(dest_dir)) > 0):
print(f'Skip downloading {name} since the directory exists')
continue
url = artifact['archive_download_url']

print('Downloading %s from %s' % (name, url))
artifact_request = urllib.request.Request(url,
headers={'Authorization': 'Bearer ' + GITHUB_TOKEN})
with urllib.request.urlopen(artifact_request) as response:
with requests.get(url, headers=headers, stream=True) as response:
tmp_zip = tempfile.NamedTemporaryFile(delete=False)
try:
#
shutil.copyfileobj(response, tmp_zip)
for chunk in response.iter_content(chunk_size=8192):
tmp_zip.write(chunk)
tmp_zip.close()

dest_dir = os.path.join(dest_path, name)
Path(dest_dir).mkdir(parents=True, exist_ok=True)
with zipfile.ZipFile(tmp_zip.name, 'r') as z:
z.extractall(dest_dir)
finally:
os.unlink(tmp_zip.name)



26 changes: 18 additions & 8 deletions build-support/stage-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,24 @@ build-support/generate-source-archive.sh $DEST_PATH
build-support/download-release-artifacts.py $WORKFLOW_ID $DEST_PATH

pushd "$DEST_PATH"
tar cvzf x64-windows-static.tar.gz x64-windows-static
tar cvzf x86-windows-static.tar.gz x86-windows-static
rm -r x64-windows-static x86-windows-static
mv macos-arm64.zip macos-arm64
mv macos-arm64/* .
mv macos-x86_64.zip macos-x86_64
mv macos-x86_64/* .
rm -rf macos-x86_64/ macos-arm64/
if [[ -d x64-windows-static.tar.gz ]]; then
tar cvzf x64-windows-static.tar.gz x64-windows-static
rm -rf x64-windows-static/
fi
if [[ -d x86-windows-static.tar.gz ]]; then
tar cvzf x86-windows-static.tar.gz x86-windows-static
rm -rf x86-windows-static/
fi
if [[ -d macos-arm64.zip ]]; then
mv macos-arm64.zip macos-arm64
mv macos-arm64/* .
rm -rf macos-arm64
fi
if [[ -d macos-x86_64.zip ]]; then
mv macos-x86_64.zip macos-x86_64
mv macos-x86_64/* .
rm -rf macos-x86_64/
fi
popd

# Sign all files
Expand Down