Skip to content

Commit ec76a6b

Browse files
authored
Add documentation for adding new crates (#12300)
This commit adds contributor documentation to our book about how to add a new crate to the workspace with respect to the crates.io-based trusted publishing workflow. The error messages in the verify-publish script have also been adjusted to point to this URL.
1 parent d73bd63 commit ec76a6b

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

docs/contributing-coding-guidelines.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,41 @@ crates to the repository and where to place/name them:
262262
workspace-local usage, meaning that the "internal" part is only relevant on
263263
crates.io.
264264

265+
### Adding Crates
266+
267+
Adding a new crate to the Wasmtime workspace takes a bit of care. Wasmtime uses
268+
crates.io trusted publishing meaning that all crates are published from CI in a
269+
specific workflow. This means that crates must exist on crates.io prior to their
270+
first publication from the Wasmtime workspace and be configured for trusted
271+
publishing.
272+
273+
The process for adding a new crate to the workspace looks like:
274+
275+
1. In a PR a new crate is added and this documentation probably isn't read to
276+
start out with.
277+
2. CI will fail in the "verify-publish" job because this crate doesn't exist on
278+
crates.io.
279+
3. The PR author should publish a placeholder crate to crates.io.
280+
4. The PR author should go to "Settings" on crates.io, click on "Add" under
281+
"Trusted Publishing", and enter the following:
282+
fields:
283+
* Publisher: `GitHub`
284+
* Repository Owner: `bytecodealliance`
285+
* Repository name: `wasmtime`
286+
* Workflow filename: `publish-to-cratesio.yml`
287+
* Environment name: `publish`
288+
5. The PR author should then check the box for requiring all publishes to use
289+
the trusted publishing workflow.
290+
6. The PR author should invite the `wasmtime-publish` user to this crate.
291+
7. A Wasmtime maintainer, with access to the BA 1password vault, will log in to
292+
crates.io as the `wasmtime-publish` user to accept the invite. Wasmtime
293+
maintainers should double-check all of the settings and remove the original
294+
owner of the crate so just `wasmtime-publish` owns the crate.
295+
296+
This ensures that when publication time rolls around the crate is already
297+
reserved on GitHub and the publication workflow will succeed. After the initial
298+
publication the crate is managed by Wasmtime maintainers.
299+
265300
### Use of `unsafe`
266301

267302
Wasmtime is a project that contains `unsafe` Rust code. Wasmtime is also used in

scripts/publish.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -587,9 +587,11 @@ fn verify(crates: &[Crate]) {
587587
"
588588
failed to get owners for {name}
589589
590-
If this crate does not exist on crates.io yet please ping wasmtime maintainers
591-
to add the crate on crates.io as a small shim. When doing so please remind them
592-
that the trusted publishing workflow must be configured as well.
590+
If this crate does not exist on crates.io yet please visit
591+
592+
https://docs.wasmtime.dev/contributing-coding-guidelines.html#adding-crates
593+
594+
and follow the instructions there
593595
",
594596
name = name,
595597
);
@@ -599,9 +601,11 @@ that the trusted publishing workflow must be configured as well.
599601
if !owners.contains("\"id\":73222,") {
600602
panic!(
601603
"
602-
crate {name} is not owned by wasmtime-publish, please run:
604+
crate {name} is not owned by wasmtime-publish, please visit:
603605
604-
cargo owner -a wasmtime-publish {name}
606+
https://docs.wasmtime.dev/contributing-coding-guidelines.html#adding-crates
607+
608+
and follow the instructions there
605609
",
606610
name = name,
607611
);
@@ -612,10 +616,11 @@ crate {name} is not owned by wasmtime-publish, please run:
612616
if false && owners.split("\"id\"").count() != 2 {
613617
panic!(
614618
"
615-
crate {name} is not exclusively owned by wasmtime-publish
619+
crate {name} is not exclusively owned by wasmtime-publish, please visit:
620+
621+
https://docs.wasmtime.dev/contributing-coding-guidelines.html#adding-crates
616622
617-
Please contact wasmtime maintainers to ensure that `wasmtime-publish` is the
618-
only listed owner of the crate.
623+
and follow the instructions there
619624
",
620625
name = name,
621626
);

0 commit comments

Comments
 (0)