From bf739853a4bf614ebc7746b5cc5dd1ef8692d217 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 24 Jun 2025 14:09:01 -0700 Subject: [PATCH 1/2] Improve publish script Pulling in some Wasmtime changes --- ci/publish.rs | 49 +++++++++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/ci/publish.rs b/ci/publish.rs index c27c6c4..5a2740a 100644 --- a/ci/publish.rs +++ b/ci/publish.rs @@ -11,7 +11,7 @@ use std::collections::HashMap; use std::env; use std::fs; use std::path::{Path, PathBuf}; -use std::process::{Command, Stdio}; +use std::process::{Command, Output, Stdio}; use std::thread; use std::time::Duration; @@ -277,19 +277,17 @@ 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 = Command::new("curl") - .arg(&format!("https://crates.io/api/v1/crates/{}", krate.name)) - .output() - .expect("failed to invoke `curl`"); - if output.status.success() - && String::from_utf8_lossy(&output.stdout) - .contains(&format!("\"newest_version\":\"{}\"", krate.version)) - { - println!( - "skip publish {} because {} is latest version", - krate.name, krate.version, - ); - return true; + match curl(&format!("https://crates.io/api/v1/crates/{}", krate.name)) { + Some(output) => { + if output.contains(&format!("\"newest_version\":\"{}\"", krate.version)) { + println!( + "skip publish {} because {} is latest version", + krate.name, krate.version, + ); + return true; + } + } + None => return false, } let status = Command::new("cargo") @@ -343,6 +341,21 @@ fn publish(krate: &Crate) -> bool { true } +fn curl(url: &str) -> Option { + let output = cmd_output( + Command::new("curl") + .arg("--user-agent") + .arg("bytecodealliance/wasmtime auto-publish script") + .arg(url), + ); + if !output.status.success() { + println!("failed to curl: {}", output.status); + println!("stderr: {}", String::from_utf8_lossy(&output.stderr)); + return None; + } + Some(String::from_utf8_lossy(&output.stdout).into()) +} + // Verify the current tree is publish-able to crates.io. The intention here is // that we'll run `cargo package` on everything which verifies the build as-if // it were published to crates.io. This requires using an incrementally-built @@ -397,3 +410,11 @@ fn verify(crates: &[Crate]) { .unwrap(); } } + +fn cmd_output(cmd: &mut Command) -> Output { + eprintln!("Running: `{:?}`", cmd); + match cmd.output() { + Ok(o) => o, + Err(e) => panic!("Failed to run `{:?}`: {}", cmd, e), + } +} From 721610a63efb6a8da3cd69c4525eb3820240e440 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 24 Jun 2025 14:11:00 -0700 Subject: [PATCH 2/2] Update user agent --- ci/publish.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/publish.rs b/ci/publish.rs index 5a2740a..1e62df6 100644 --- a/ci/publish.rs +++ b/ci/publish.rs @@ -345,7 +345,7 @@ fn curl(url: &str) -> Option { let output = cmd_output( Command::new("curl") .arg("--user-agent") - .arg("bytecodealliance/wasmtime auto-publish script") + .arg("bytecodealliance/wasm-component-ld auto-publish script") .arg(url), ); if !output.status.success() {