Open Engineering Hello
A minimal Rust crate published by Open Engineering.
Account Setup
Go to your crates.io account settings -> API Tokens and create a new token.
For this first test, give it a descriptive name such as:
open-engineering-crates-publishing
Then, in your terminal, run:
Cargo will prompt:
please paste the token found on https://crates.io/me below
Paste the crates.io token. Cargo stores the credentials locally, so do not put tokens in Cargo.toml, .env, or Git.
For CI/CD later, don't use your locally stored token. Instead use a crates.io token through your CI secret store, exposed as:
CARGO_REGISTRY_TOKEN
For this first manual publication, though, cargo login is exactly what you want.
Pre-requisites
On Linux or a GitHub Codespace, run:
|
Choose the default installation (1).
Then load Cargo into your current shell:
Verify:
You should now have all three:
rustc ...
cargo ...
rustup ...
Tip: Add Rust installation to the repository's Dev Container configuration so every fresh Codespace gets cargo automatically rather than requiring this manual setup.
Usage
Add the crate:
Note: If you get the error: cannot add `open-engineering-hello` as a dependency to itself, Cargo correctly refsuses to add a package as its own dependency. For the crate repository, you do not need that command. Just test the library directly:
The command cargo add open-engineering-hello belongs in a different project that consumes your published crate.
For example, after publishing, you could test installation like this:
Then replace src/main.rs with:
And run:
Expected output:
Hello, Open Engineering!
Open Engineering
This crate is part of the Open Engineering ecosystem.
Before publishing
From the repository root:
Then inspect what Cargo intends to upload:
And perform the important dry run:
Once everything looks right:
Then assign the GitHub team you created (i.e. crates):
That produces a rather nice first end-to-end proof:
GitHub
open-engineering-crates/source
|
| cargo publish
V
crates.io
open-engineering-hello
|
| ownership
V
github:open-engineering-crates:crates
|
| documentation
V
docs.rs
open-engineering-hello