|
| 1 | +# Publishing to crates.io |
| 2 | + |
| 3 | +This document describes how to publish the ServiceStack Rust client library to crates.io. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +1. Create an account on [crates.io](https://crates.io/) |
| 8 | +2. Get your API token from [crates.io/me](https://crates.io/me) |
| 9 | +3. Configure your token locally: |
| 10 | + ```bash |
| 11 | + cargo login <your-api-token> |
| 12 | + ``` |
| 13 | + |
| 14 | +## Pre-publication Checklist |
| 15 | + |
| 16 | +Before publishing, ensure: |
| 17 | + |
| 18 | +- [ ] All tests pass: `cargo test` |
| 19 | +- [ ] Documentation builds without warnings: `cargo doc --no-deps` |
| 20 | +- [ ] Package builds successfully: `cargo package` |
| 21 | +- [ ] Version number is correct in `Cargo.toml` |
| 22 | +- [ ] `CHANGELOG.md` is updated |
| 23 | +- [ ] `README.md` is accurate and up-to-date |
| 24 | +- [ ] License file exists and is correct |
| 25 | +- [ ] All code is committed and pushed to GitHub |
| 26 | + |
| 27 | +## Package Verification |
| 28 | + |
| 29 | +1. Build and test the package: |
| 30 | + ```bash |
| 31 | + cargo build |
| 32 | + cargo test |
| 33 | + ``` |
| 34 | + |
| 35 | +2. Verify the package contents: |
| 36 | + ```bash |
| 37 | + cargo package --list |
| 38 | + ``` |
| 39 | + |
| 40 | +3. Build the package to check for issues: |
| 41 | + ```bash |
| 42 | + cargo package |
| 43 | + ``` |
| 44 | + |
| 45 | +4. Test the packaged version: |
| 46 | + ```bash |
| 47 | + cargo package |
| 48 | + cd target/package |
| 49 | + cargo test |
| 50 | + ``` |
| 51 | + |
| 52 | +## Publishing |
| 53 | + |
| 54 | +Once all checks pass, publish to crates.io: |
| 55 | + |
| 56 | +```bash |
| 57 | +cargo publish |
| 58 | +``` |
| 59 | + |
| 60 | +This will: |
| 61 | +1. Package your crate |
| 62 | +2. Upload it to crates.io |
| 63 | +3. Make it available for download via `cargo install` |
| 64 | + |
| 65 | +## Post-Publication |
| 66 | + |
| 67 | +After publishing: |
| 68 | + |
| 69 | +1. Create a GitHub release: |
| 70 | + - Tag: `v0.1.0` |
| 71 | + - Title: `ServiceStack Rust v0.1.0` |
| 72 | + - Description: Copy from CHANGELOG.md |
| 73 | + |
| 74 | +2. Verify the package appears on crates.io: |
| 75 | + - Visit https://crates.io/crates/servicestack |
| 76 | + - Check that documentation is generated at https://docs.rs/servicestack |
| 77 | + |
| 78 | +3. Test installation: |
| 79 | + ```bash |
| 80 | + cargo new test-project |
| 81 | + cd test-project |
| 82 | + cargo add servicestack |
| 83 | + cargo build |
| 84 | + ``` |
| 85 | + |
| 86 | +## Version Updates |
| 87 | + |
| 88 | +For future releases: |
| 89 | + |
| 90 | +1. Update version in `Cargo.toml` |
| 91 | +2. Update `CHANGELOG.md` with new changes |
| 92 | +3. Commit and push changes |
| 93 | +4. Run through the pre-publication checklist |
| 94 | +5. Publish with `cargo publish` |
| 95 | +6. Create a new GitHub release |
| 96 | + |
| 97 | +## Troubleshooting |
| 98 | + |
| 99 | +- **Publishing fails**: Check that all required fields in `Cargo.toml` are filled |
| 100 | +- **Documentation fails to build**: Run `cargo doc` locally to see errors |
| 101 | +- **Tests fail**: Run `cargo test` to identify and fix failing tests |
| 102 | +- **Version conflict**: Ensure version number is incremented from last published version |
0 commit comments