MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / publish

Function publish

scripts/publish.rs:437–470  ·  view source on GitHub ↗
(krate: &Crate)

Source from the content-addressed store, hash-verified

435}
436
437fn publish(krate: &Crate) -> bool {
438 if !krate.publish {
439 return true;
440 }
441
442 // First make sure the crate isn't already published at this version. This
443 // script may be re-run and there's no need to re-attempt previous work.
444 let Some(output) = curl(&format!(
445 "https://crates.io/api/v1/crates/{}/versions",
446 krate.name
447 )) else {
448 return false;
449 };
450 if output.contains(&format!("\"num\":\"{}\"", krate.version)) {
451 println!(
452 "skip publish {} because {} is already published",
453 krate.name, krate.version,
454 );
455 return true;
456 }
457
458 let status = cmd_status(
459 Command::new("cargo")
460 .arg("publish")
461 .current_dir(krate.manifest.parent().unwrap())
462 .arg("--no-verify"),
463 );
464 if !status.success() {
465 println!("FAIL: failed to publish `{}`: {}", krate.name, status);
466 return false;
467 }
468
469 true
470}
471
472fn curl(url: &str) -> Option<String> {
473 let output = cmd_output(

Callers 1

mainFunction · 0.85

Calls 8

curlFunction · 0.85
cmd_statusFunction · 0.85
newFunction · 0.50
containsMethod · 0.45
argMethod · 0.45
unwrapMethod · 0.45
parentMethod · 0.45
successMethod · 0.45

Tested by

no test coverage detected