Skip to content

Commit

Permalink
Update publish script skipping versions (#9432)
Browse files Browse the repository at this point in the history
Instead of only checking the latest version check the list of recently
published versions to determine if a version is already published.
  • Loading branch information
alexcrichton authored Oct 9, 2024
1 parent 0538c0f commit 44ecb52
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions scripts/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 44ecb52

Please sign in to comment.