# Open Engineering Hello
A minimal Rust crate published by Open Engineering.
## Account Setup
Go to your [crates.io account settings -> API Tokens](https://crates.io/settings/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:
```bash
cargo login
```
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:
```bash
Choose the default installation (1).
Then load Cargo into your current shell:
```bash
source "$HOME/.cargo/env"
```
Verify:
```bash
rustc --version
cargo --version
rustup --version
```
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:
```bash
cargo add open-engineering-hello
```
**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:
```bash
cargo test
```
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:
```bash
cd /tmp
cargo new hello-consumer
cd hello-consumer
cargo add open-engineering-hello
```
Then replace `src/main.rs` with:
```rust
fn main() {
println!("{}", open_engineering_hello::hello());
}
```
And run:
```bash
cargo run
```
Expected output:
```
Hello, Open Engineering!
```
# Open Engineering
This crate is part of the Open Engineering ecosystem.
https://open-engineering.io
### Before publishing
From the repository root:
```bash
cargo fmt --check
cargo test
cargo clippy --all-targets --all-features -- -D warnings
cargo package
```
Then inspect what Cargo intends to upload:
```bash
cargo package --list
```
And perform the important dry run:
```bash
cargo publish --dry-run
```
Once everything looks right:
```bash
cargo publish
```
Then assign the GitHub team you created (i.e. `crates`):
```bash
cargo owner \
--add github:open-engineering-crates:crates \
open-engineering-hello
```
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
```