fix: don't error if a version already published (#21455)

This commit is contained in:
Luca Casonato 2023-12-04 12:40:58 +01:00 committed by GitHub
parent 0a738dc49d
commit 7d5ddc462c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -388,14 +388,28 @@ async fn perform_publish(
.send()
.await?;
let mut task = parse_response::<PublishingTask>(response)
.await
.with_context(|| {
format!(
"Failed to publish @{}/{} at {}",
package.scope, package.package, package.version
)
})?;
let res = parse_response::<PublishingTask>(response).await;
let mut task = match res {
Ok(task) => task,
Err(err) if err.code == "versionAlreadyExists" => {
println!(
"{} @{}/{}@{}",
colors::yellow("Skipping, already published"),
package.scope,
package.package,
package.version
);
continue;
}
Err(err) => {
return Err(err).with_context(|| {
format!(
"Failed to publish @{}/{} at {}",
package.scope, package.package, package.version
)
})
}
};
let interval = std::time::Duration::from_secs(2);
while task.status != "success" && task.status != "failure" {