wai-quantum-cli release: read the SHA-256 files over the private network #376

Merged
dcharlot merged 1 commit from wai/quantum-cli-formulae-private into main 2026-10-21 04:12:39 -04:00

View file

@ -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):