Skip to content

Commit eb54a90

Browse files
authored
Verify owners on crates.io for in-tree crates (#11313)
When adding crates over time (or renaming) we've often forgotten to add either the `wasmtime-publish` user or the `wasmtime-publish` team. Add a check that looks at the `owners` endpoint on crates.io and verifies that the two are present.
1 parent 5351998 commit eb54a90

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

scripts/publish.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ fn verify(crates: &[Crate]) {
550550
}
551551

552552
fn verify_and_vendor(krate: &Crate) {
553+
verify_crates_io(krate);
554+
553555
let mut cmd = Command::new("cargo");
554556
cmd.arg("package")
555557
.arg("--manifest-path")
@@ -607,4 +609,30 @@ fn verify(crates: &[Crate]) {
607609
version
608610
);
609611
}
612+
613+
fn verify_crates_io(krate: &Crate) {
614+
let name = &krate.name;
615+
let Some(owners) = curl(&format!("https://crates.io/api/v1/crates/{name}/owners")) else {
616+
panic!("failed to get owners for {name}", name = name);
617+
};
618+
619+
let assert_owner = |owner: &str| {
620+
let owner_json = format!("\"{owner}\"");
621+
if !owners.contains(&owner_json) {
622+
panic!(
623+
"
624+
crate {name} is not owned by {owner}, please run:
625+
626+
cargo owner -a {owner} {name}
627+
",
628+
name = name
629+
);
630+
}
631+
};
632+
633+
// the wasmtime-publish github user
634+
assert_owner("wasmtime-publish");
635+
// the BA team which can publish crates
636+
assert_owner("github:bytecodealliance:wasmtime-publish");
637+
}
610638
}

0 commit comments

Comments
 (0)