# Publishing to Crates.io

This document logs the requirements and steps taken to publish `sutra_afm_lib` to Crates.io.

## Prerequisites
1. **Crates.io Account:** Create an account at [crates.io](https://crates.io).
2. **Email Verification:** Your email must be verified in your [Crates.io profile](https://crates.io/settings/profile).
3. **API Token:** Generate a "Publish" token in [Settings > API Tokens](https://crates.io/settings/tokens).

## Initial Setup
Before the first publish, log in via the terminal:
```bash
cargo login <your-token>
```
*Note: This saves the token locally in `~/.cargo/credentials.toml`.*

## Publishing Steps

### 1. Verify Metadata
Ensure `Cargo.toml` has:
- `description`
- `license` (e.g., "MIT")
- `repository`
- `readme`
- `keywords` and `categories`

### 2. Clean Build & Test
```bash
cargo clean
cargo test -- --test-threads=1
```

### 3. Publish Command
Because this crate uses a `build.rs` script that interacts with the Swift package manager (which modifies `src/Package.resolved`), standard verification may fail. Use the `--no-verify` flag to proceed:

```bash
cargo publish --no-verify
```

## Troubleshooting
- **Dirty Repository:** If you have uncommitted changes, use `cargo publish --allow-dirty`.
- **Metadata Missing:** Crates.io will reject the upload if the `description` or `license` fields are missing.
- **Verification Failed:** If `Verification failed` occurs due to `build.rs` modifications, ensure you are using `--no-verify`.
