kodegen-bundler-release
Production-quality release management and multi-platform bundling for Rust workspaces.
Features
- π Atomic Release Operations - All-or-nothing releases with automatic rollback on failure
- π¦ Multi-Platform Bundling - Create native installers for Linux, macOS, and Windows
- π Version Synchronization - Automatically update internal workspace dependencies
- π³ Pure Rust Git - No
gitCLI dependency, uses gix - π Dependency-Ordered Publishing - Publishes packages in correct topological order
- π‘οΈ Isolated Workflow - Operates in temporary clones to protect your working directory
- βΈοΈ Resume & Rollback - Continue interrupted releases or undo failed ones
- π― GitHub Integration - Automated release creation and artifact uploads
- π Code Signing - macOS Developer ID and Windows Authenticode support
Quick Start
Installation
# Install from crates.io
# OR build from source
Basic Usage
# Release with patch version bump (0.1.0 β 0.1.1)
# Preview changes without making modifications
# Create platform-specific bundles
# Resume an interrupted release
# Rollback a failed release
What It Does
Release Workflow
When you run a release command, the tool:
- Validates workspace structure and dependencies
- Clones your repository to
/tmp/kodegen-release-{timestamp}/(isolated environment) - Updates version numbers in all
Cargo.tomlfiles - Synchronizes internal workspace dependency versions
- Commits changes with formatted commit message
- Tags the release (e.g.,
v0.1.0) - Signs artifacts (macOS only, optional)
- Bundles platform packages (optional, enabled by default)
- Pushes to remote repository
- Creates GitHub release with notes
- Uploads signed artifacts and bundles
- Publishes packages to crates.io in dependency order
- Cleans up temporary clone
Your working directory is never modified. All operations happen in an isolated temporary clone.
Supported Package Formats
Linux Packages
- Debian (.deb) - Ubuntu, Debian, and derivatives
- RPM (.rpm) - Fedora, RHEL, CentOS, openSUSE
- AppImage (.AppImage) - Portable, self-contained executables
macOS Packages
- DMG (.dmg) - macOS disk image installer
Windows Packages
- NSIS (.exe) - Lightweight installer via NSIS
Usage Examples
Release Commands
# Standard release workflow
# Bump minor version (0.1.x β 0.2.0)
# Bump major version (0.x.y β 1.0.0)
# Dry run (preview without changes)
# Release without pushing to remote
# Release without GitHub release
# Release without creating bundles
# Keep temp clone for debugging
Bundle Commands
# Bundle for current platform
# Bundle specific platform
# Bundle without rebuilding binaries
# Bundle and upload to GitHub release
# Bundle for specific architecture
State Management Commands
# Resume interrupted release
# Check current release status
# Rollback failed release
# Force rollback (even for completed releases)
# Clean up state without rollback
Validation Commands
# Validate workspace structure
# Verbose validation output
Configuration
Environment Variables
Required for Publishing
# crates.io API token
# GitHub API token (for GitHub releases)
# OR
macOS Code Signing (Optional)
# Add to ~/.zshrc (loaded automatically on startup)
# Optional: App Store Connect API (for notarization)
Cargo.toml Metadata
Configure bundling behavior in your workspace Cargo.toml:
[]
= "com.example.myapp"
= "Example Inc."
= ["assets/icon.png"]
= "Developer Tool"
= "My awesome application"
[]
= ["libc6"]
[]
= ["glibc"]
Building Locally
Prerequisites
- Rust nightly (edition 2024):
rustup install nightly && rustup default nightly - Git: For version control operations
- Platform-specific tools:
- Linux: dpkg-dev, rpm, fakeroot
- macOS: Xcode Command Line Tools
- Windows: NSIS
Build Commands
# Build release binary
# Run tests
# Format code
# Lint
Cross-Platform Bundling via Docker
For creating Linux/Windows bundles from macOS (or vice versa), use Docker:
# Build Docker image (includes Wine, NSIS)
# Create Windows NSIS installer from Linux/macOS
# Create Linux packages from macOS
The tool automatically detects when cross-platform bundling is needed and uses Docker containers with appropriate toolchains.
Architecture Highlights
Isolated Release Strategy
All release operations execute in temporary clones to ensure your working directory remains untouched:
- Clone created at
/tmp/kodegen-release-{timestamp}/ - Active temp path saved to
~/.kodegen-temp-releasefor resume support - Automatic cleanup after completion (unless
--keep-temp) - Resume capability across sessions
Dependency-Ordered Publishing
The tool analyzes your workspace dependency graph and publishes packages in the correct order:
Tier 0: [utils, schema] β No dependencies
Tier 1: [mcp-tool, mcp-client] β Depends on Tier 0
Tier 2: [tools-git, tools-fs] β Depends on Tier 1
Tier 3: [kodegen] β Depends on Tier 2
Packages within the same tier publish in parallel (configurable concurrency), while tiers execute sequentially.
State-Based Resume
Release progress is tracked in .cyrup_release_state.json with phases:
- Validation
- VersionUpdate
- GitOperations
- GitHubRelease
- Publishing
- Completed
If a release is interrupted, resume continues from the last successful checkpoint.
Format-Preserving TOML Editing
Version updates preserve your Cargo.toml formatting using toml_edit:
- Comments preserved
- Custom formatting maintained
- Whitespace unchanged
- Only version fields modified
Bundler Integration Contract
The release workflow integrates with kodegen-bundler-bundle via a strict contract that guarantees artifact location and existence.
Architecture Detection
The release workflow detects the target architecture at compile time using Rust's cfg attributes:
return Ok; // macOS ARM64
return Ok; // Linux x86_64
This ensures the correct architecture is always used for artifact naming, even during cross-compilation.
Output Path Construction
The release workflow constructs the complete output path including architecture:
// Detect actual target architecture
let arch = detect_target_architecture?; // "arm64", "amd64", etc.
// Construct filename with explicit architecture
let filename = format!;
let output_path = temp_dir.join.join;
Example filenames:
kodegen_2.0.0_arm64.deb(Debian ARM64)kodegen_2.0.0_amd64.deb(Debian x86_64)kodegen-2.0.0-arm64.dmg(macOS ARM64)kodegen_2.0.0_x64_setup.exe(Windows x64)
Contract Enforcement
The release workflow passes the full path to the bundler and enforces the contract:
let output = new
.arg.arg
.arg.arg
.arg.arg
.arg.arg
.arg.arg // β Contract: bundler puts artifact HERE
.arg
.output?;
// Check exit code
if !output.status.success
// Contract verification: exit code 0 means file MUST exist
if !output_path.exists
// File is guaranteed to exist at output_path
Bundler Responsibilities
When called with --output-binary, the bundler guarantees:
- Directory creation: All parent directories in the path are created
- Artifact movement: The artifact is moved (not copied) to the exact specified path
- Existence verification: File existence is verified before returning
- Exit code contract: Exit code 0 means file guaranteed to exist at specified path
Why This Design?
This contract-based design provides:
- No path guessing: Release workflow specifies exact paths, bundler complies
- Architecture correctness: Compile-time detection prevents mismatch
- Robust verification: Exit code enforcement prevents silent failures
- Future-proof: New architectures work without bundler code changes
- Clear responsibility: Release owns naming, bundler owns creation and movement
Communication Protocol
- Exit codes: Contractual (0 = success with file at specified location)
- stdout: Diagnostic only (human-readable progress, not for parsing)
- stderr: Diagnostic only (error details, not for contract verification)
Troubleshooting
"Binary not found in target/release"
Solution: Build binaries before bundling:
# OR let bundler build automatically
"Another release is in progress"
Solution: Resume or clean up the existing release:
# OR
"GitHub token not found"
Solution: Set the required environment variable:
# OR add to ~/.bashrc or ~/.zshrc
macOS Code Signing Fails
Solution: Verify credentials are loaded:
| |
Docker Build Failures
Solution: Increase Docker memory limit:
Development
Project Structure
kodegen-bundler-release/
βββ src/
β βββ bundler/ # Platform-specific bundling logic
β βββ cli/ # Command parsing and orchestration
β βββ error/ # Error types and handling
β βββ git/ # Git operations (via gix)
β βββ github/ # GitHub API integration
β βββ publish/ # crates.io publishing logic
β βββ state/ # Release state persistence
β βββ version/ # Version bumping and TOML editing
β βββ workspace/ # Workspace analysis and graphs
βββ Cargo.toml
βββ README.md
Running Tests
# All tests
# Specific module
# With output
Debug Logging
RUST_LOG=debug
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes with tests
- Format code:
cargo fmt - Lint:
cargo clippy -- -D warnings - Submit a pull request
Code Standards
- Edition 2024 Rust
#![deny(unsafe_code)]except for audited FFI calls- Comprehensive error messages with recovery suggestions
- All public APIs documented
License
Dual-licensed under Apache-2.0 OR MIT.
See LICENSE.md for details.
Credits
Part of the KODEGEN.α΄Ιͺ project - blazing-fast MCP tools for AI-powered code generation.
Key Dependencies
- gix - Pure Rust Git implementation
- clap - Command-line argument parsing
- toml_edit - Format-preserving TOML editing
- petgraph - Graph algorithms for dependency ordering
- reqwest - HTTP client for GitHub API
Support
- Issues: GitHub Issues
- Documentation: docs.rs
- Website: kodegen.ai