Skip to content

Commit

Permalink
Fix release script (#459)
Browse files Browse the repository at this point in the history
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 <joerichey@google.com>
  • Loading branch information
josephlr committed Feb 10, 2024
1 parent f4d3dbb commit af70710
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions scripts/ci-release.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down

0 comments on commit af70710

Please sign in to comment.