|
6 | 6 | crate_version = cargo_toml["package"]["version"]
|
7 | 7 | print("Detected crate version " + crate_version)
|
8 | 8 |
|
9 |
| -api_url = "https://crates.io/api/v1/crates/x86_64/versions" |
10 |
| -crates_io_versions = requests.get(api_url).json() |
| 9 | +api_url = "https://crates.io/api/v1/crates/x86_64/" + crate_version |
| 10 | +released_version = requests.get(api_url).json() |
11 | 11 |
|
12 |
| -new_version = True |
13 |
| -for version in crates_io_versions["versions"]: |
| 12 | +if "version" in released_version: |
| 13 | + version = released_version["version"] |
14 | 14 | assert (version["crate"] == "x86_64")
|
15 |
| - if version["num"] == crate_version: |
16 |
| - new_version = False |
17 |
| - break |
| 15 | + assert (version["num"] == crate_version) |
| 16 | + print("Version " + crate_version + " already exists on crates.io") |
18 | 17 |
|
19 |
| -if new_version: |
20 |
| - print("Could not find version " + crate_version + " on crates.io; creating a new release") |
| 18 | +else: |
| 19 | + print("Could not find version " + crate_version + |
| 20 | + " on crates.io; creating a new release") |
21 | 21 |
|
22 | 22 | print(" Running `cargo publish`")
|
23 | 23 | subprocess.run(["cargo", "publish"], check=True)
|
24 | 24 |
|
25 | 25 | tag_name = "v" + crate_version
|
26 | 26 | print(" Tagging commit as " + tag_name)
|
27 |
| - sha = subprocess.run(["git", "rev-parse", "HEAD"], check=True, stdout=subprocess.PIPE).stdout.decode("utf-8").strip() |
| 27 | + sha = subprocess.run(["git", "rev-parse", "HEAD"], check=True, |
| 28 | + stdout=subprocess.PIPE).stdout.decode("utf-8").strip() |
28 | 29 | subprocess.run([
|
29 | 30 | "gh", "api", "/repos/rust-osdev/x86_64/git/refs",
|
30 | 31 | "-X", "POST", "-H", "Accept: application/vnd.github.v3+json",
|
|
33 | 34 | ])
|
34 | 35 |
|
35 | 36 | print(" Done")
|
36 |
| -else: |
37 |
| - print("Version " + crate_version + " already exists on crates.io") |
0 commit comments