# 🚀 Rust SDK Publishing Guide for crates.io
Complete guide for publishing the WOWSQL Rust SDK to crates.io.
---
## 📦 Package Information
- **Crate Name**: `WOWSQL`
- **Version**: `1.0.0`
- **Registry**: crates.io
- **URL**: https://crates.io/crates/WOWSQL
- **Documentation**: https://docs.rs/WOWSQL
---
## ✅ Pre-Publishing Checklist
### Package Files
- [x] `Cargo.toml` - Package configuration
- [x] `src/` - Source files
- [x] `README.md` - Package documentation
- [x] `LICENSE` - MIT License
- [x] `examples/` - Usage examples
### Code Quality
- [x] All imports correct
- [x] No compiler warnings (`cargo clippy`)
- [x] Documentation comments (`cargo doc`)
- [x] Example code works
- [x] Version number correct
- [x] Metadata complete in `Cargo.toml`
---
## 🔧 Prerequisites
### 1. Install Rust
**All Platforms:**
```bash
# Install Rust using rustup
# Or on Windows, download and run rustup-init.exe
# From: https://rustup.rs/
```
**Verify Installation:**
```bash
rustc --version
cargo --version
```
**Windows-Specific Requirements:**
Choose one of the following toolchains:
**Option A: GNU Toolchain (Recommended for simplicity)**
- Requires: MinGW/MSYS2
- Install MSYS2: https://www.msys2.org/
- After installation, run in MSYS2 terminal:
```bash
pacman -Syu
pacman -S mingw-w64-x86_64-toolchain
```
- Add `C:\msys64\mingw64\bin` to your system PATH
- Set Rust toolchain: `rustup default stable-x86_64-pc-windows-gnu`
**Option B: MSVC Toolchain**
- Requires: Visual Studio 2017+ or Build Tools for Visual Studio
- Download: https://visualstudio.microsoft.com/downloads/
- Install "Desktop development with C++" workload
- Set Rust toolchain: `rustup default stable-x86_64-pc-windows-msvc`
### 2. Create crates.io Account
1. **Go to crates.io:**
- Visit: https://crates.io/
- Click "Log in with GitHub" (top right)
- Authorize crates.io to access your GitHub account
2. **Get API Token:**
- After logging in, go to: https://crates.io/me
- Click "New Token"
- Token name: `WOWSQL SDK Upload`
- Copy the token (starts with `cargo_...`)
- **Save it immediately** - you won't see it again!
3. **Configure Cargo:**
```bash
cargo login YOUR_TOKEN_HERE
```
This saves the token to `~/.cargo/credentials` (or `%USERPROFILE%\.cargo\credentials` on Windows).
**Verify:**
```bash
cargo owner --list
```
### 3. Verify Cargo.toml
Ensure `Cargo.toml` has all required fields:
```toml
[package]
name = "WOWSQL"
version = "1.0.0"
edition = "2021"
authors = ["WOWSQL Team <support@wowsql.com>"]
description = "Official Rust SDK for WOWSQL - MySQL Backend-as-a-Service with S3 Storage"
license = "MIT"
repository = "https://github.com/wowsql/wowsql-rust"
homepage = "https://wowsql.com"
documentation = "https://docs.rs/WOWSQL"
keywords = ["mysql", "database", "backend", "s3", "storage", "baas"]
categories = ["database", "web-programming"]
```
---
## 📝 Publishing Steps
### Step 1: Navigate to Rust SDK
```bash
cd sdk/rust
```
### Step 2: Clean and Build
```bash
# Clean previous builds
cargo clean
# Build in release mode
cargo build --release
# Check for warnings
cargo clippy -- -D warnings
# Check formatting
cargo fmt --check
```
### Step 3: Run Tests
```bash
# Run all tests
cargo test
# Run tests with output
cargo test -- --nocapture
```
### Step 4: Generate Documentation
```bash
# Generate docs locally
cargo doc --no-deps --open
# Verify documentation builds
cargo doc --no-deps
```
### Step 5: Check Package
```bash
# Validate package before publishing
cargo package
# Check what will be published
cargo package --list
```
This creates a `.crate` file in `target/package/` and validates:
- ✅ All files are included
- ✅ `Cargo.toml` is valid
- ✅ No excluded files are present
- ✅ Package size is acceptable
### Step 6: Dry Run (Verify Package)
```bash
# Verify without publishing
cargo publish --dry-run
```
This will:
- ✅ Validate package structure
- ✅ Check `Cargo.toml`
- ✅ Verify file sizes
- ✅ Check for required files
- ✅ Show what will be published
**Expected Output:**
```
Updating crates.io index
Packaging WOWSQL v1.0.0 (/path/to/sdk/rust)
Verifying WOWSQL v1.0.0 (/path/to/sdk/rust)
Compiling WOWSQL v1.0.0 (/path/to/sdk/rust/target/package/WOWSQL-1.0.0)
Finished dev [unoptimized + debuginfo] target(s) in 2.34s
Uploading WOWSQL v1.0.0 (/path/to/sdk/rust)
```
### Step 7: Publish to crates.io
```bash
cargo publish
```
You'll see:
```
Updating crates.io index
Packaging WOWSQL v1.0.0 (/path/to/sdk/rust)
Verifying WOWSQL v1.0.0 (/path/to/sdk/rust)
Compiling WOWSQL v1.0.0 (/path/to/sdk/rust/target/package/WOWSQL-1.0.0)
Finished dev [unoptimized + debuginfo] target(s) in 2.34s
Uploading WOWSQL v1.0.0 (/path/to/sdk/rust)
Uploaded WOWSQL v1.0.0 to registry
```
**Note**: Publishing is permanent! You cannot unpublish a version after 24 hours.
### Step 8: Verify Publication
Wait 5-10 minutes, then:
1. **Check crates.io:**
- Visit: https://crates.io/crates/WOWSQL
- You should see version 1.0.0!
2. **Check docs.rs:**
- Visit: https://docs.rs/WOWSQL
- Documentation should be available automatically
3. **Test Installation:**
```bash
cargo new test-WOWSQL
cd test-WOWSQL
[dependencies]
WOWSQL = "1.0"
cargo build
use WOWSQL::WOWSQLClient;
fn main() {
println!("✅ WOWSQL Rust SDK imported successfully!");
}
cargo run
```
---
## 🎯 Quick Publish Script
Create `publish.sh`:
```bash
#!/bin/bash
set -e
VERSION=${1:-1.0.0}
echo "🚀 Publishing WOWSQL Rust SDK v$VERSION..."
echo ""
# Step 1: Clean
echo "🧹 Step 1/7: Cleaning..."
cargo clean
echo "✅ Clean complete"
echo ""
# Step 2: Format check
echo "📝 Step 2/7: Checking formatting..."
read -p "Continue anyway? (y/N): " confirm
if [[ $confirm != [yY] ]]; then
exit 1
fi
}
echo "✅ Formatting OK"
echo ""
# Step 3: Clippy
echo "🔍 Step 3/7: Running clippy..."
read -p "Continue anyway? (y/N): " confirm
if [[ $confirm != [yY] ]]; then
exit 1
fi
}
echo "✅ Clippy passed"
echo ""
# Step 4: Build
echo "📦 Step 4/7: Building..."
cargo build --release
if [ $? -ne 0 ]; then
echo "❌ Build failed!"
exit 1
fi
echo "✅ Build complete"
echo ""
# Step 5: Test
echo "🧪 Step 5/7: Running tests..."
cargo test
if [ $? -ne 0 ]; then
echo "❌ Tests failed!"
exit 1
fi
echo "✅ Tests passed"
echo ""
# Step 6: Package
echo "📦 Step 6/7: Packaging..."
cargo package
if [ $? -ne 0 ]; then
echo "❌ Packaging failed!"
exit 1
fi
echo "✅ Package ready"
echo ""
# Step 7: Publish
echo "🚀 Step 7/7: Publishing to crates.io..."
read -p "Ready to publish v$VERSION? (y/N): " confirm
if [[ $confirm == [yY] ]]; then
cargo publish
echo ""
echo "✨ =========================================="
echo " SUCCESS! Published to crates.io"
echo "=========================================="
echo ""
echo "📦 Crate: WOWSQL"
echo "🔢 Version: $VERSION"
echo "🔗 URL: https://crates.io/crates/WOWSQL"
echo "📚 Docs: https://docs.rs/WOWSQL"
echo ""
echo "📥 Users can install with:"
echo " cargo add WOWSQL"
echo ""
else
echo "❌ Publishing cancelled"
exit 0
fi
```
**Windows PowerShell (`publish.ps1`):**
```powershell
param(
[string]$Version = "1.0.0"
)
Write-Host ""
Write-Host "🚀 Publishing WOWSQL Rust SDK v$Version..." -ForegroundColor Green
Write-Host ""
# Step 1: Clean
Write-Host "🧹 Step 1/7: Cleaning..." -ForegroundColor Cyan
cargo clean
Write-Host "✅ Clean complete" -ForegroundColor Green
Write-Host ""
# Step 2: Format check
Write-Host "📝 Step 2/7: Checking formatting..." -ForegroundColor Cyan
cargo fmt --check
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ Code not formatted. Run: cargo fmt" -ForegroundColor Yellow
$confirm = Read-Host "Continue anyway? (y/N)"
if ($confirm -ne 'y' -and $confirm -ne 'Y') {
exit 1
}
}
Write-Host "✅ Formatting OK" -ForegroundColor Green
Write-Host ""
# Step 3: Clippy
Write-Host "🔍 Step 3/7: Running clippy..." -ForegroundColor Cyan
cargo clippy -- -D warnings
if ($LASTEXITCODE -ne 0) {
Write-Host "⚠️ Clippy found issues" -ForegroundColor Yellow
$confirm = Read-Host "Continue anyway? (y/N)"
if ($confirm -ne 'y' -and $confirm -ne 'Y') {
exit 1
}
}
Write-Host "✅ Clippy passed" -ForegroundColor Green
Write-Host ""
# Step 4: Build
Write-Host "📦 Step 4/7: Building..." -ForegroundColor Cyan
cargo build --release
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Build failed!" -ForegroundColor Red
exit 1
}
Write-Host "✅ Build complete" -ForegroundColor Green
Write-Host ""
# Step 5: Test
Write-Host "🧪 Step 5/7: Running tests..." -ForegroundColor Cyan
cargo test
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Tests failed!" -ForegroundColor Red
exit 1
}
Write-Host "✅ Tests passed" -ForegroundColor Green
Write-Host ""
# Step 6: Package
Write-Host "📦 Step 6/7: Packaging..." -ForegroundColor Cyan
cargo package
if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Packaging failed!" -ForegroundColor Red
exit 1
}
Write-Host "✅ Package ready" -ForegroundColor Green
Write-Host ""
# Step 7: Publish
Write-Host "🚀 Step 7/7: Publishing to crates.io..." -ForegroundColor Cyan
$confirm = Read-Host "Ready to publish v$Version? (y/N)"
if ($confirm -eq 'y' -or $confirm -eq 'Y') {
cargo publish
Write-Host ""
Write-Host "✨ ==========================================" -ForegroundColor Green
Write-Host " SUCCESS! Published to crates.io" -ForegroundColor Green
Write-Host "==========================================" -ForegroundColor Green
Write-Host ""
Write-Host "📦 Crate: WOWSQL"
Write-Host "🔢 Version: $Version"
Write-Host "🔗 URL: https://crates.io/crates/WOWSQL"
Write-Host "📚 Docs: https://docs.rs/WOWSQL"
Write-Host ""
Write-Host "📥 Users can install with:"
Write-Host " cargo add WOWSQL"
Write-Host ""
} else {
Write-Host "❌ Publishing cancelled" -ForegroundColor Yellow
exit 0
}
```
**Make executable and run:**
```bash
chmod +x publish.sh
./publish.sh 1.0.0
```
---
## 🐛 Troubleshooting
### Error: "cargo: command not found"
**Solution**: Install Rust:
```bash
```
### Error: "no token found"
**Solution**: Login to crates.io:
```bash
cargo login YOUR_TOKEN_HERE
```
Get token from: https://crates.io/me
### Error: "crate name 'WOWSQL' is already taken"
**Solution**: The crate name is already registered. Options:
1. Use a different name in `Cargo.toml`
2. Contact the owner of `WOWSQL` crate
3. Use a different name like `WOWSQL-sdk`
### Error: "crate already uploaded"
**Solution**: Version already exists. Increment version in `Cargo.toml`:
```toml
version = "1.0.1" # or 1.1.0, 2.0.0
```
Then publish again.
### Error: "package size exceeds limit"
**Solution**:
- Check `.cargoignore` excludes unnecessary files
- Remove large files from repository
- Maximum package size is 10MB
### Error: "failed to verify package tarball"
**Solution**:
```bash
# Clean and rebuild
cargo clean
cargo package
```
### Error: "error calling dlltool 'dlltool.exe': program not found" (Windows)
This error occurs on Windows when using the GNU toolchain without MinGW/MSYS2 installed, or when dependencies need to link Windows libraries.
**Solution 1: Switch to MSVC Toolchain (Requires Visual Studio)**
The MSVC toolchain doesn't require `dlltool.exe`, but it requires Visual Studio Build Tools:
```powershell
# Check current toolchain
rustup show
# Install MSVC toolchain if not installed
rustup toolchain install stable-x86_64-pc-windows-msvc
# Set as default
rustup default stable-x86_64-pc-windows-msvc
# Verify
rustup show
# Try packaging again
cargo clean
cargo package
```
**⚠️ Important:** MSVC toolchain requires Visual Studio 2017+ or Build Tools for Visual Studio with C++ workload installed. If you get `link.exe not found` error, see the next troubleshooting section.
**Solution 2: Install MinGW/MSYS2 (Recommended for GNU Toolchain)**
This is the easiest solution if you're using the GNU toolchain:
1. **Download and Install MSYS2:**
- Visit: https://www.msys2.org/
- Download the installer (usually `msys2-x86_64-*.exe`)
- Run the installer and follow the prompts
- Default installation path: `C:\msys64`
2. **Open MSYS2 Terminal** (not PowerShell/CMD) and run:
```bash
pacman -Syu
pacman -S mingw-w64-x86_64-toolchain
```
3. **Add MinGW to System PATH:**
**Option A: Using PowerShell (Run as Administrator):**
```powershell
# Add to user PATH (recommended)
[Environment]::SetEnvironmentVariable(
"Path",
[Environment]::GetEnvironmentVariable("Path", "User") + ";C:\msys64\mingw64\bin",
"User"
)
```
**Option B: Manual (Windows Settings):**
- Press `Win + X` → System → Advanced system settings
- Click "Environment Variables"
- Under "User variables", select "Path" → Edit
- Click "New" → Add: `C:\msys64\mingw64\bin`
- Click OK on all dialogs
4. **Restart your terminal/PowerShell** (or restart your IDE)
5. **Verify dlltool is available:**
```powershell
dlltool --version
```
You should see version information.
6. **Try packaging again:**
```powershell
cd sdk/rust
cargo clean
cargo package
```
**Solution 3: Skip Verification (Not Recommended)**
Only use this if you're certain the package is correct:
```powershell
# Package without verification (not recommended)
cargo package --no-verify
```
**Note:** `cargo publish` will still verify the package, so this only helps with `cargo package`.
### Error: "linker `link.exe` not found" (Windows MSVC)
This error occurs when using the MSVC toolchain without Visual Studio Build Tools installed.
**Solution 1: Install Visual Studio Build Tools (For MSVC Toolchain)**
1. **Download Build Tools:**
- Visit: https://visualstudio.microsoft.com/downloads/
- Scroll down to "Tools for Visual Studio"
- Download "Build Tools for Visual Studio 2022"
2. **Install with C++ Workload:**
- Run the installer
- Select "Desktop development with C++" workload
- Click "Install"
- This installs `link.exe` and other MSVC tools
3. **Restart your terminal** and try again:
```powershell
cargo clean
cargo package
```
**Solution 2: Switch to GNU Toolchain (Easier Alternative)**
If you don't want to install Visual Studio Build Tools, use the GNU toolchain instead:
```powershell
# Switch to GNU toolchain
rustup default stable-x86_64-pc-windows-gnu
# Install MinGW/MSYS2 (see Solution 2 in dlltool error section)
# Then add to PATH and try again
cargo clean
cargo package
```
**Note:** The GNU toolchain is perfectly fine for Rust development on Windows and doesn't require Visual Studio.
### Error: "missing license field"
**Solution**: Add license to `Cargo.toml`:
```toml
license = "MIT"
```
### Error: "invalid characters in crate name"
**Solution**: Crate names must be lowercase alphanumeric with hyphens:
- ✅ `WOWSQL`
- ✅ `WOWSQL-sdk`
- ❌ `WOWSQL`
- ❌ `wow_mysql`
### Error: "documentation failed to build"
**Solution**:
```bash
# Check docs locally
cargo doc --no-deps
# Fix any documentation errors
# Common issues:
# - Missing doc comments on public items
# - Invalid markdown in doc comments
# - Broken code examples
```
---
## ✅ Post-Publishing Tasks
### 1. Verify Publication (< 5 minutes)
Visit https://crates.io/crates/WOWSQL
Check:
- [ ] Crate page loads
- [ ] Version 1.0.0 is live
- [ ] README renders correctly
- [ ] All metadata correct
- [ ] Download count shows
### 2. Check Documentation (< 5 minutes)
Visit https://docs.rs/WOWSQL
Check:
- [ ] Documentation builds successfully
- [ ] All public APIs documented
- [ ] Examples work
- [ ] Links are correct
**Note**: docs.rs automatically builds documentation from crates.io. It may take 10-30 minutes.
### 3. Test Installation (< 10 minutes)
```bash
# Create test project
cargo new test-WOWSQL
cd test-WOWSQL
# Add dependency
cargo add WOWSQL
# Edit src/main.rs
cat > src/main.rs << 'EOF'
use WOWSQL::WOWSQLClient;
fn main() {
println!("✅ WOWSQL Rust SDK imported successfully!");
}
EOF
# Build and run
cargo build
cargo run
```
### 4. Create Git Tag
```bash
git tag -a v1.0.0-rust -m "Rust SDK v1.0.0 - Initial Release"
git push origin v1.0.0-rust
```
### 5. Create GitHub Release
1. Go to: https://github.com/wowsql/wowsql-rust/releases/new
2. Tag: `v1.0.0-rust`
3. Title: "Rust SDK v1.0.0 - Initial Release"
4. Description: Copy from `README.md` or create release notes
5. Publish
### 6. Update Documentation
- [ ] Add Rust SDK to main README
- [ ] Update documentation site
- [ ] Add Rust quickstart guide
- [ ] Update API reference
- [ ] Add Rust examples
### 7. Announce Release
Post to:
- [ ] Twitter/X
- [ ] LinkedIn
- [ ] Discord community
- [ ] Reddit (r/rust, r/rustlang)
- [ ] Dev.to blog post
- [ ] Company blog
**Announcement Template:**
```markdown
🎉 WOWSQL Rust SDK v1.0.0 Released!
Build MySQL-powered Rust apps in minutes!
Features:
✨ Full CRUD operations
📦 S3 Storage support
🔍 Advanced filtering
⚡ Async/await with Tokio
🎯 Fluent API
🔒 Type-safe with Serde
Install:
cargo add WOWSQL
Docs: https://docs.rs/WOWSQL
Crate: https://crates.io/crates/WOWSQL
#Rust #RustLang #MySQL #BaaS #AsyncRust
```
---
## 📈 Package Metrics
Monitor these after publishing:
**crates.io Stats:**
- Downloads (total, recent)
- Dependents (other crates using yours)
- Recent downloads
- All-time downloads
**docs.rs Stats:**
- Documentation views
- Search rankings
**GitHub Stats:**
- Stars
- Forks
- Issues
- Pull requests
**Goals:**
- Week 1: 100+ downloads
- Month 1: 1,000+ downloads
- Month 3: 5,000+ downloads
---
## 🔄 Updating the Package
When releasing new versions:
1. **Update version** in `Cargo.toml`
2. **Update** `CHANGELOG.md` (if you have one)
3. **Run** `cargo clippy` and `cargo fmt`
4. **Test** changes: `cargo test`
5. **Package**: `cargo package`
6. **Dry run**: `cargo publish --dry-run`
7. **Publish**: `cargo publish`
8. **Tag** release in Git
9. **Announce** update
**Versioning:**
- **MAJOR** (1.0.0 → 2.0.0): Breaking changes
- **MINOR** (1.0.0 → 1.1.0): New features
- **PATCH** (1.0.0 → 1.0.1): Bug fixes
**Example:**
```bash
# Edit Cargo.toml: version = "1.0.1"
cargo clippy
cargo fmt
cargo test
cargo publish
```
---
## 📚 Additional Resources
- **crates.io Guide**: https://doc.rust-lang.org/cargo/reference/publishing.html
- **Cargo Book**: https://doc.rust-lang.org/cargo/
- **docs.rs**: https://docs.rs/
- **Semantic Versioning**: https://semver.org/
- **Rust API Guidelines**: https://rust-lang.github.io/api-guidelines/
---
## 🎊 Ready to Launch!
**Everything is prepared. When you're ready:**
1. ✅ Run `cargo clippy` and `cargo fmt`
2. ✅ Run `cargo test`
3. ✅ Run `cargo package` to validate
4. ✅ Run `cargo publish --dry-run` to verify
5. ✅ Run `cargo publish` to go live
6. ✅ Verify on crates.io
7. ✅ Check docs.rs (wait 10-30 min)
8. ✅ Test installation
9. ✅ Create git tags
10. ✅ Announce to community
**Good luck with the launch! 🚀**
---
Made with ❤️ by the WOWSQL Team