build_release: Add retry functionality for GitHub upload

This commit is contained in:
Florian Bruhin 2019-09-25 21:09:44 +02:00
parent fe32e00a4e
commit f2a09a97b2
1 changed files with 12 additions and 3 deletions

View File

@ -407,6 +407,7 @@ def github_upload(artifacts, tag):
tag: The name of the release tag
"""
import github3
import github3.exceptions
utils.print_title("Uploading to github...")
token = read_github_token()
@ -421,9 +422,17 @@ def github_upload(artifacts, tag):
raise Exception("No release found for {!r}!".format(tag))
for filename, mimetype, description in artifacts:
with open(filename, 'rb') as f:
basename = os.path.basename(filename)
asset = release.upload_asset(mimetype, basename, f)
while True:
try:
with open(filename, 'rb') as f:
basename = os.path.basename(filename)
asset = release.upload_asset(mimetype, basename, f)
except github3.exceptions.ConnectionError as e:
utils.print_col('Failed to upload: {}'.format(e), 'red')
print("Press Enter to retry...")
input()
else:
break
asset.edit(basename, description)