From 44ecb523a517cd9813f896543a0938047026d58a Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Oct 2024 13:48:22 -0500 Subject: [PATCH] Update publish script skipping versions (#9432) 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 df0bb1248cf4..930cf81b71d4 100644 --- a/scripts/publish.rs +++ b/scripts/publish.rs @@ -425,15 +425,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;