From c4800135d8ce2e7c07dda8a5f0810e372e335bd4 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 3a3542086601..9df7655d221c 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;