# Publishing Guide for cargo-size
## Prerequisites
1. **crates.io Account**: Sign up at [crates.io](https://crates.io) with your GitHub account
2. **API Token**: Generate an API token from your crates.io account settings
3. **Login**: Run `cargo login YOUR_API_TOKEN` to authenticate
## Publishing Steps
### 1. Final Checks
Before publishing, make sure to:
- [ ] Update the `authors` field in `Cargo.toml` with your actual name and email
- [ ] Update the `repository` and `homepage` URLs to point to your actual GitHub repo
- [ ] Test the package: `cargo package`
- [ ] Verify documentation: `cargo doc --no-deps`
### 2. Publish to crates.io
```bash
# Publish the package
cargo publish
# Or publish without uploading (dry run)
cargo publish --dry-run
```
### 3. Verify Publication
After publishing:
1. Check your package at: `https://crates.io/crates/cargo-size`
2. Documentation will be automatically generated at: `https://docs.rs/cargo-size`
## Post-Publication
### Installation for Users
Once published, users can install your tool with:
```bash
cargo install cargo-size
```
### Updating the Package
To publish updates:
1. Update the version in `Cargo.toml`
2. Update `CHANGELOG.md` (recommended)
3. Run `cargo publish` again
## Documentation on docs.rs
docs.rs automatically generates documentation from your crate's doc comments. Key points:
- Documentation is generated from `///` and `//!` comments
- Examples in doc comments are tested automatically
- Documentation appears at `https://docs.rs/cargo-size`
## Best Practices
1. **Semantic Versioning**: Follow semver (major.minor.patch)
2. **Changelog**: Keep a `CHANGELOG.md` file
3. **Examples**: Include usage examples in documentation
4. **Tests**: Add tests for better reliability
5. **CI/CD**: Consider GitHub Actions for automated testing
## Troubleshooting
### Common Issues
- **Name already taken**: Choose a different crate name
- **Authentication errors**: Re-run `cargo login`
- **Metadata errors**: Check `Cargo.toml` formatting
- **Documentation errors**: Fix doc comment syntax
### Getting Help
- [crates.io documentation](https://doc.crates.io/cargo-commands/commands/cargo-publish.html)
- [docs.rs documentation](https://docs.rs/about)
- [Rust Book on Publishing](https://doc.rust-lang.org/book/ch14-02-publishing-to-crates-io.html)