A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Migrate this workspace to using trusted publishing (#12257)
Alex Crichton11931e6791d0
diff --git a/.github/workflows/publish-to-cratesio.yml b/.github/workflows/publish-to-cratesio.ymlindex 46d3611a3f..2f71296787 100644--- a/.github/workflows/publish-to-cratesio.yml+++ b/.github/workflows/publish-to-cratesio.yml@@ -9,21 +9,27 @@ on:tags:- 'v*'+permissions:+ id-token: write+jobs:publish:if: github.repository == 'bytecodealliance/wasmtime'runs-on: ubuntu-latest+ environment: publishsteps:- uses: actions/checkout@v4with:submodules: true- run: rustup update stable && rustup default stable+ - uses: rust-lang/crates-io-auth-action@v1+ id: auth- run: |rustc scripts/publish.rs./publish publishenv:- CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}-+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}+# Manifest and publish the wasi-preview1-component-adapter-provider- uses: ./.github/actions/fetch-run-id- uses: ./.github/actions/build-adapter-provider@@ -31,4 +37,4 @@ jobs:run-id: ${{ env.COMMIT_RUN_ID }}- run: cargo publish -p wasi-preview1-component-adapter-provider --allow-dirtyenv:- CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}+ CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}diff --git a/scripts/publish.rs b/scripts/publish.rsindex 88366a2254..e2729302f0 100644--- a/scripts/publish.rs+++ b/scripts/publish.rs@@ -472,34 +472,6 @@ fn publish(krate: &Crate) -> bool {return false;}- // After we've published then make sure that the `wasmtime-publish` group is- // added to this crate for future publications. If it's already present- // though we can skip the `cargo owner` modification.- let Some(output) = curl(&format!(- "https://crates.io/api/v1/crates/{}/owners",- krate.name- )) else {- return false;- };- if output.contains("wasmtime-publish") {- println!(- "wasmtime-publish already listed as an owner of {}",- krate.name- );- return true;- }-- // Note that the status is ignored here. This fails most of the time because- // the owner is already set and present, so we only want to add this to- // crates which haven't previously been published.- run_cmd(- Command::new("cargo")- .arg("owner")- .arg("-a")- .arg("github:bytecodealliance:wasmtime-publish")- .arg(&krate.name),- );-true}@@ -614,26 +586,42 @@ fn verify(crates: &[Crate]) {fn verify_crates_io(krate: &Crate) {let name = &krate.name;let Some(owners) = curl(&format!("https://crates.io/api/v1/crates/{name}/owners")) else {- panic!("failed to get owners for {name}", name = name);+ panic!(+ "+failed to get owners for {name}++If this crate does not exist on crates.io yet please ping wasmtime maintainers+to add the crate on crates.io as a small shim. When doing so please remind them+that the trusted publishing workflow must be configured as well.+",+ name = name,+ );};- let assert_owner = |owner: &str| {- let owner_json = format!("\"{owner}\"");- if !owners.contains(&owner_json) {- panic!(- "-crate {name} is not owned by {owner}, please run:+ // This is the id of the `wasmtime-publish` user on crates.io+ if !owners.contains("\"id\":73222,") {+ panic!(+ "+crate {name} is not owned by wasmtime-publish, please run:- cargo owner -a {owner} {name}+ cargo owner -a wasmtime-publish {name}",- name = name- );- }- };+ name = name,+ );+ }++ // TODO: waiting for trusted publishing to be proven to work before+ // activating this.+ if false && owners.split("\"id\"").count() != 2 {+ panic!(+ "+crate {name} is not exclusively owned by wasmtime-publish- // the wasmtime-publish github user- assert_owner("wasmtime-publish");- // the BA team which can publish crates- assert_owner("github:bytecodealliance:wasmtime-publish");+Please contact wasmtime maintainers to ensure that `wasmtime-publish` is the+only listed owner of the crate.+",+ name = name,+ );+ }}}