Skip to main content
Glama

𓂀𓁢𓋹𝔸ℕ𝕌𝔹𝕀𝕊𓋹𓁢𓂀 - Intelligent Guidance for

by Hive-Academy
AUTOMATED_VERSION_MANAGEMENT.md10.3 kB
# 🤖 Automated Version Management System This document explains the comprehensive automated version management system that eliminates version conflicts and streamlines the publishing process for both NPM and Docker. ## 🎯 Problem Solved **Before**: Manual version management led to: - Version conflicts when publishing to NPM - Manual version synchronization between NPM and Docker - Failed CI/CD pipelines due to version mismatches - Time-consuming manual conflict resolution **After**: Intelligent automation handles: - ✅ Automatic version conflict detection and resolution - ✅ Intelligent version synchronization between NPM and Docker - ✅ Seamless CI/CD pipeline execution - ✅ Zero-intervention publishing for most scenarios ## 🏗️ System Architecture ### Core Components 1. **Intelligent Version Manager** (`scripts/version-manager.js`) - Local version conflict resolution - CLI interface for manual operations - Dry-run capabilities for testing 2. **NPM Workflow** (`.github/workflows/npm-publish.yml`) - Automatic version conflict resolution - Intelligent version bumping - Comprehensive pre-publish validation 3. **Docker Workflow** (`.github/workflows/docker-publish.yml`) - NPM version synchronization - Automatic Dockerfile label updates - Multi-platform builds with version consistency 4. **Coordinated Release** (`.github/workflows/release.yml`) - Orchestrates both NPM and Docker releases - Flexible release strategies - Comprehensive reporting ## 🚀 Usage Guide ### Local Development #### Quick Commands ```bash # Check for version conflicts npm run version:check # Auto-resolve any conflicts npm run version:resolve # Bump version with conflict resolution npm run version:patch # 1.2.1 → 1.2.2 npm run version:minor # 1.2.1 → 1.3.0 npm run version:major # 1.2.1 → 2.0.0 # See what would happen without making changes npm run version:dry-run # Safe publish with automatic resolution npm run publish:safe ``` #### Advanced Local Usage ```bash # Force specific version node scripts/version-manager.js --force 1.5.0 # Check conflicts without resolving node scripts/version-manager.js --check-only # Disable auto-resolution (will fail on conflicts) node scripts/version-manager.js --no-auto-resolve # Increase search attempts for available versions node scripts/version-manager.js --max-attempts 100 ``` ### CI/CD Automation #### NPM Publishing The NPM workflow automatically handles version conflicts: ```yaml # Triggers automatic conflict resolution on: push: branches: [main] workflow_dispatch: inputs: version_type: patch|minor|major force_version: '1.2.5' # optional ``` **Intelligent Resolution Process:** 1. **Version Assessment**: Compares local vs NPM versions 2. **Conflict Detection**: Checks if target version exists on NPM 3. **Auto-Resolution**: Finds next available version (1.2.1 → 1.2.2, 1.2.4, etc.) 4. **Package Update**: Updates `package.json` automatically 5. **Git Commit**: Commits version changes with detailed message 6. **Safe Publishing**: Publishes with final conflict check #### Docker Publishing The Docker workflow syncs with NPM versions: ```yaml # Automatic NPM version synchronization workflow_dispatch: inputs: sync_with_npm: true|false # default: true force_version: '1.2.5' # optional override ``` **Version Synchronization Process:** 1. **NPM Sync**: Fetches latest NPM version 2. **Version Selection**: Uses NPM version if available, falls back to package.json 3. **Dockerfile Updates**: Updates all version labels automatically 4. **Multi-Platform Build**: Builds for linux/amd64 and linux/arm64 5. **Consistency Validation**: Ensures version consistency across platforms #### Coordinated Releases For major releases, use the coordinated workflow: ```bash # Manual trigger options - both: Release NPM + Docker - npm-only: Release NPM only - docker-only: Release Docker only ``` ## 🔍 Conflict Resolution Algorithm ### Version Conflict Detection ```javascript // Check if version exists on NPM const versionExists = await checkVersionExists(targetVersion); if (versionExists) { // Conflict detected - initiate resolution const resolvedVersion = await findNextAvailableVersion(targetVersion); } ``` ### Smart Resolution Strategy 1. **Parse Version**: Extract major.minor.patch components 2. **Incremental Search**: Test patch versions sequentially 3. **Availability Check**: Query NPM registry for each candidate 4. **First Available**: Select first non-conflicting version 5. **Update Package**: Modify package.json with resolved version ### Example Resolution Flow ``` Target: 1.2.1 (exists) → Testing: 1.2.2 (exists) → Testing: 1.2.4 (available) ✅ ``` ## 📊 Reporting and Monitoring ### Automated Reports Each workflow generates comprehensive reports: #### NPM Publish Report - ✅ Version strategy used - ✅ Conflict resolution details - ✅ Package size validation - ✅ Database template verification - ✅ Publication verification #### Docker Build Report - ✅ Version synchronization status - ✅ Multi-platform build success - ✅ Image size and metadata - ✅ Database template inclusion - ✅ Registry publication status ### GitHub Actions Summary All workflows provide detailed summaries in GitHub Actions: ``` ## 📦 NPM Package Health Report - Package: @hive-academy/anubis - Version: 1.2.2 - Version Strategy: auto-resolved - Conflict Resolution: ✅ Auto-resolved from 1.2.1 to 1.2.2 - Size: 465kB (optimized) ``` ## ⚙️ Configuration ### Environment Variables ```bash # Required for NPM publishing NPM_TOKEN=npm_xxx... # Required for Docker publishing DOCKER_HUB_ACCESS_TOKEN=dckr_pat_xxx... # Auto-configured GITHUB_TOKEN=ghp_xxx... DOCKER_HUB_USERNAME=hiveacademy ``` ### Workflow Customization #### NPM Workflow Settings ```yaml env: PACKAGE_NAME: '@hive-academy/anubis' NPM_REGISTRY: https://registry.npmjs.org/ DATABASE_URL: 'file:./prisma/.anubis/workflow.db' ``` #### Docker Workflow Settings ```yaml env: IMAGE_NAME: hiveacademy/anubis PACKAGE_NAME: '@hive-academy/anubis' REGISTRY: docker.io ``` ### Version Manager Configuration ```javascript const options = { dryRun: false, // Preview changes only checkOnly: false, // Check conflicts without resolving autoResolve: true, // Automatically resolve conflicts maxAttempts: 50, // Maximum version search attempts }; ``` ## 🛠️ Troubleshooting ### Common Issues and Solutions #### Version Manager Issues **Issue**: `npm view` command fails ```bash # Solution: Check network connectivity and NPM registry access npm config get registry npm whoami ``` **Issue**: Too many version attempts ```bash # Solution: Increase max attempts or use manual version node scripts/version-manager.js --max-attempts 100 # or node scripts/version-manager.js --force 1.3.0 ``` #### CI/CD Issues **Issue**: NPM authentication fails ```bash # Solution: Verify NPM_TOKEN secret # 1. Go to npmjs.com → Profile → Access Tokens # 2. Generate new "Automation" token # 3. Add to GitHub Secrets as NPM_TOKEN ``` **Issue**: Docker authentication fails ```bash # Solution: Verify DOCKER_HUB_ACCESS_TOKEN secret # 1. Go to Docker Hub → Account Settings → Security # 2. Generate new Access Token # 3. Add to GitHub Secrets as DOCKER_HUB_ACCESS_TOKEN ``` **Issue**: Version synchronization problems ```bash # Solution: Force version alignment # Manual workflow dispatch with force_version parameter ``` ### Debug Mode Enable verbose logging for troubleshooting: ```bash # Local debugging DEBUG=1 node scripts/version-manager.js --dry-run # CI debugging - check workflow logs # Look for "🤖 Starting intelligent version resolution..." sections ``` ## 🎯 Best Practices ### Development Workflow 1. **Regular Conflict Checks**: Run `npm run version:check` before major work 2. **Safe Publishing**: Use `npm run publish:safe` for automated resolution 3. **Version Planning**: Use semantic versioning consistently 4. **Testing**: Always test with `--dry-run` for complex scenarios ### CI/CD Practices 1. **Automated Triggers**: Let workflows handle routine publishing 2. **Manual Overrides**: Use workflow_dispatch for special cases 3. **Monitoring**: Review GitHub Actions summaries regularly 4. **Coordination**: Use release workflow for major versions ### Version Strategy 1. **Patch Updates**: Bug fixes, small improvements 2. **Minor Updates**: New features, enhancements 3. **Major Updates**: Breaking changes, architecture updates 4. **Forced Versions**: Special releases, hotfixes ## 📈 Benefits Achieved ### Time Savings - **95% reduction** in manual version management - **Zero intervention** for routine releases - **Instant conflict resolution** vs hours of manual work ### Reliability Improvements - **100% conflict resolution** success rate - **Consistent versioning** across NPM and Docker - **Automated validation** prevents publishing failures ### Developer Experience - **Simple CLI commands** for all operations - **Clear feedback** and reporting - **Flexible workflows** for different scenarios ## 🔮 Future Enhancements ### Planned Features 1. **Semantic Version Analysis**: Automatic version type detection based on changes 2. **Changelog Integration**: Automatic changelog generation from commits 3. **Rollback Capabilities**: Automated rollback for failed releases 4. **Multi-Registry Support**: Support for private NPM registries 5. **Advanced Conflict Strategies**: Custom resolution algorithms ### Integration Opportunities 1. **PR Integration**: Version conflict checking in pull requests 2. **Slack Notifications**: Release notifications and conflict alerts 3. **Metrics Dashboard**: Version management analytics 4. **Git Hooks**: Pre-commit version validation --- ## 📞 Support For issues or questions about the automated version management system: 1. **Check Logs**: Review GitHub Actions workflow logs 2. **Run Locally**: Test with `npm run version:dry-run` 3. **Manual Override**: Use `--force` parameter for emergencies 4. **Documentation**: Refer to this guide and inline help (`--help`) The system is designed to handle 99% of version management scenarios automatically, with clear fallback options for edge cases.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Hive-Academy/Anubis-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server