1
0
Fork 0
mirror of https://github.com/BLAKE3-team/BLAKE3 synced 2024-05-18 20:36:07 +02:00

add another retry loop to upload_github_release_asset.py

While we're at it, black format the .py files in this directory.
This commit is contained in:
Jack O'Connor 2022-11-20 17:08:49 -08:00
parent 537e96747a
commit 56b72b1738
2 changed files with 17 additions and 8 deletions

View File

@ -9,8 +9,9 @@ import sys
ROOT = Path(__file__).parent.parent.parent
RUST_TARGET = sys.argv[1]
subprocess.run(["cargo", "build", "--target", sys.argv[1], "--release"],
cwd=ROOT / "b3sum")
subprocess.run(
["cargo", "build", "--target", sys.argv[1], "--release"], cwd=ROOT / "b3sum"
)
if platform.system() == "Windows":
original_exe_name = "b3sum.exe"

View File

@ -3,6 +3,7 @@
import github
import os
import sys
import time
RETRIES = 10
@ -10,7 +11,7 @@ g = github.Github(os.environ["GITHUB_TOKEN"])
tag_name = os.environ["GITHUB_TAG"]
tag_prefix = "refs/tags/"
if tag_name.startswith(tag_prefix):
tag_name = tag_name[len(tag_prefix):]
tag_name = tag_name[len(tag_prefix) :]
assert len(sys.argv) == 2
asset_path = sys.argv[1]
asset_name = os.path.basename(asset_path)
@ -34,13 +35,20 @@ except github.GithubException as github_error:
else:
raise
releases = list(repo.get_releases())
for release in releases:
if release.tag_name == tag_name:
break
else:
def get_release():
for i in range(RETRIES):
releases = list(repo.get_releases())
for release in releases:
if release.tag_name == tag_name:
return release
print(f"Release for tag {repr(tag_name)} not found. Retrying...")
time.sleep(1)
raise RuntimeError("no release for tag " + repr(tag_name))
release = get_release()
print("Uploading " + repr(asset_path) + "...")
for i in range(RETRIES):
try: