wai-quantum-cli release: read the SHA-256 files over the private network #376
1 changed files with 8 additions and 2 deletions
|
|
@ -16,7 +16,13 @@ import urllib.request
|
|||
|
||||
version, tag, api, repo, public, out = sys.argv[1:7]
|
||||
token = os.environ.get("FORGE_TOKEN", "")
|
||||
headers = {"Authorization": f"token {token}"} if token else {}
|
||||
# A user agent of our own: the public address refuses the library's default one.
|
||||
headers = {"User-Agent": "wai-quantum-release"}
|
||||
if token:
|
||||
headers["Authorization"] = f"token {token}"
|
||||
# The forge's own address, as the API's: the SHA-256 files are read there, over the
|
||||
# private network, not through the public address the formula points users to.
|
||||
web = api.rsplit("/api/v1", 1)[0]
|
||||
|
||||
|
||||
def get(url):
|
||||
|
|
@ -33,7 +39,7 @@ def digest(archive):
|
|||
if archive not in assets or archive + ".sha256" not in assets:
|
||||
print(f"note: {archive} is not attached; left out", file=sys.stderr)
|
||||
return None
|
||||
return get(assets[archive + ".sha256"]["browser_download_url"]).decode().split()[0]
|
||||
return get(f"{web}/{repo}/releases/download/{tag}/{archive}.sha256").decode().split()[0]
|
||||
|
||||
|
||||
def url(archive):
|
||||
|
|
|
|||
Loading…
Reference in a new issue