From af70710699978effb3fb9aad048a35982914f7d7 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Sat, 10 Feb 2024 07:02:54 -0800 Subject: [PATCH] Fix release script (#459) This switches to using the sparse index as reccomended by: https://crates.io/data-access#api Once merged, this should automatically release v0.14.12 (see #457). Signed-off-by: Joe Richey --- scripts/ci-release.py | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/scripts/ci-release.py b/scripts/ci-release.py index 0c289299..cd701125 100644 --- a/scripts/ci-release.py +++ b/scripts/ci-release.py @@ -1,22 +1,20 @@ import json import subprocess import tomllib -from urllib.request import urlopen +import urllib.request with open("Cargo.toml", "rb") as f: cargo_toml = tomllib.load(f) crate_version = cargo_toml["package"]["version"] print("Detected crate version " + crate_version) -api_url = "https://crates.io/api/v1/crates/x86_64/" + crate_version -version_data = json.loads(urlopen(api_url).read()) - -if "version" in version_data: - version = version_data["version"] - assert (version["crate"] == "x86_64") - assert (version["num"] == crate_version) - print("Version " + crate_version + " already exists on crates.io") - +index_url = "https://index.crates.io/x8/6_/x86_64" +for line in urllib.request.urlopen(index_url): + version_info = json.loads(line) + assert (version_info["name"] == "x86_64") + if version_info["vers"] == crate_version: + print("Version " + crate_version + " already exists on crates.io") + break else: print("Could not find version " + crate_version + " on crates.io; creating a new release")