From 42c4c2bcdae3946af67e5c3660d1cfc68817e444 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Oct 2024 10:56:03 -0700 Subject: [PATCH] Update publish script skipping versions Instead of only checking the latest version check the list of recently published versions to determine if a version is already published. --- scripts/publish.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/scripts/publish.rs b/scripts/publish.rs index 325ed1d81e73..8c1535b87659 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -419,15 +419,16 @@ fn publish(krate: &Crate) -> bool { // First make sure the crate isn't already published at this version. This // script may be re-run and there's no need to re-attempt previous work. - let output = cmd_output( - Command::new("curl").arg(&format!("https://crates.io/api/v1/crates/{}", krate.name)), - ); + let output = cmd_output(Command::new("curl").arg(&format!( + "https://crates.io/api/v1/crates/{}/versions", + krate.name + ))); if output.status.success() && String::from_utf8_lossy(&output.stdout) - .contains(&format!("\"newest_version\":\"{}\"", krate.version)) + .contains(&format!("\"num\":\"{}\"", krate.version)) { println!( - "skip publish {} because {} is latest version", + "skip publish {} because {} is already published", krate.name, krate.version, ); return true;