Changesets CI/CD Migration - Implementation Summary
Status: ✅ Implementation Complete (Hybrid Approach Enabled) Date: 2025-10-11 (Initial) | 2025-10-12 (Hybrid Upgrade) Branch: staging
Quick Links
Section titled “Quick Links”- Releasing Guide - How to use changesets
- Platform Architecture - Overall repository structure
What Was Implemented
Section titled “What Was Implemented”1. Changesets Foundation ✅
Section titled “1. Changesets Foundation ✅”Created:
.changeset/config.json- Changesets configuration.changeset/README.md- Changesets documentation
Modified:
package.json(root) - Added Changesets, Husky, lint-staged dependencies and scripts
Package Renaming:
apps/webapp/package.json→@erp-unlocked/webappapps/crm/package.json→@erp-unlocked/crmapps/marketing/package.json→@erp-unlocked/marketing
New Packages:
apps/pdf-api/package.json→@erp-unlocked/pdf-apiapps/pdf-worker/package.json→@erp-unlocked/pdf-worker
2. Pre-commit Hooks ✅
Section titled “2. Pre-commit Hooks ✅”Created:
.husky/pre-commit- Enforces changeset creation for app/package changes
Features:
- Runs lint-staged for code formatting
- Checks for changeset presence when apps/ or packages/ modified
- Skips check for merge commits
- Provides helpful error messages
3. Version-Aware CI/CD ✅
Section titled “3. Version-Aware CI/CD ✅”Created:
.github/workflows/version-aware-build.yml- New conditional build pipeline.github/workflows/release.yml- Automated release management
Renamed:
.github/workflows/ci-cd-pipeline.yml→ci-cd-pipeline-legacy.yml(backup)
Features:
- Detects version changes per service using Changesets
- Only builds Docker images for changed services
- Uses semantic versions for Docker tags (1.2.3 instead of staging-abc123)
- Supports PR builds with
pr-{commit}tags - Conditional deployments to staging and production
- Hybrid Release Strategy:
- Staging: Auto-merge Version PRs for fast iteration
- Production: Manual review for safety
4. Documentation ✅
Section titled “4. Documentation ✅”Created:
docs/DEVELOPER_WORKFLOW.md- Complete developer guide with examplesdocs/ci-cd-versioning-migration.md- Migration plan and timelinedocs/CHANGESETS_IMPLEMENTATION_SUMMARY.md- This file
5. Hybrid Release Strategy ✅ (Updated 2025-10-12)
Section titled “5. Hybrid Release Strategy ✅ (Updated 2025-10-12)”Modified:
.github/workflows/release.yml- Upgraded to Option C Hybrid Approach
Changes:
- Enable on Staging: Release workflow now runs on both
mainandstagingbranches - Fixed Changesets Action: Changed from
publishparameter toversionparameter withcreateGithubReleases: false - Auto-Merge for Staging: Added
auto-merge-stagingjob that automatically merges Version PRs on staging branch - PR Number Output: Release job now outputs the PR number for downstream jobs
Behavior:
- Staging Branch: Version PRs are automatically merged when all CI checks pass (fast iteration)
- Main Branch: Version PRs require manual review before merge (production safety)
New Commands Available
Section titled “New Commands Available”For Developers
Section titled “For Developers”# Create a changeset (run after making changes)pnpm changeset
# Check what would be releasedpnpm version:check
# Detailed view of pending releasespnpm version:previewFor Maintainers
Section titled “For Maintainers”# Apply version changes from changesetspnpm version:apply
# Prepare for release (version + install)pnpm release:prepare
# Publish packages (automated via CI)pnpm release:publishHow It Works
Section titled “How It Works”Developer Flow
Section titled “Developer Flow”- Make Changes - Modify code in any app or package
- Create Changeset - Run
pnpm changesetbefore committing - Select Packages - Choose which apps/packages changed
- Choose Version - Select patch/minor/major bump
- Write Summary - Describe the changes (becomes changelog)
- Commit - Commit both code and changeset file
- Push PR - Create pull request to staging
PR Build Flow
Section titled “PR Build Flow”- PR opened/updated triggers
version-aware-build.yml - Detects which apps have file changes
- Builds Docker images only for changed apps
- Tags images with
pr-{commit-sha}format - Does NOT deploy (build only for validation)
Release Flow (Staging/Main)
Section titled “Release Flow (Staging/Main)”- PR merged to staging or main
version-aware-build.ymldetects changeset-based versions- Builds Docker images with semantic version tags (1.2.3)
- Pushes images to GHCR
- Deploys to appropriate environment (staging/production)
- Only changed services are built and deployed
Automated Release (Hybrid Approach)
Section titled “Automated Release (Hybrid Approach)”Staging Branch (Fully Automated):
- Changesets detected on staging branch
release.ymlcreates “Version Packages” PRauto-merge-stagingjob automatically enables auto-merge- PR merges automatically when all CI checks pass
- Triggers new build with updated versions
- Services auto-deploy to staging
Timeline: ~10-15 minutes from push to deployment
Main Branch (Manual Review):
- Changesets detected on main branch
release.ymlcreates “Version Packages” PR- Maintainer manually reviews the Version PR
- When manually merged, triggers new build with updated versions
- Services auto-deploy to production
Timeline: Controlled by maintainer approval
File Structure Changes
Section titled “File Structure Changes”erp-unlocked/├── .changeset/ # NEW│ ├── config.json # Changesets config│ └── README.md # Changesets docs├── .github/│ ├── workflows/│ │ ├── version-aware-build.yml # NEW - Main CI/CD│ │ └── release.yml # NEW - Automated releases│ └── workflows-backup/│ └── ci-cd-pipeline-legacy.yml # MOVED - Backup (disabled)├── .husky/│ └── pre-commit # NEW - Changeset enforcement├── apps/│ ├── webapp/│ │ └── package.json # MODIFIED - Renamed @erp-unlocked/webapp│ ├── crm/│ │ └── package.json # MODIFIED - Renamed @erp-unlocked/crm│ ├── marketing/│ │ └── package.json # MODIFIED - Renamed @erp-unlocked/marketing│ ├── pdf-api/│ │ └── package.json # NEW - Enables versioning│ └── pdf-worker/│ └── package.json # NEW - Enables versioning├── docs/│ ├── DEVELOPER_WORKFLOW.md # NEW - Developer guide│ ├── ci-cd-versioning-migration.md # NEW - Migration plan│ └── CHANGESETS_IMPLEMENTATION_SUMMARY.md # NEW - This file└── package.json # MODIFIED - Added dependenciesBreaking Changes
Section titled “Breaking Changes”For Developers
Section titled “For Developers”- Changesets Required - Must run
pnpm changesetbefore committing app/package changes - Pre-commit Hook - Blocks commits without changeset (can skip with
--no-verify) - Package Names - Internal package names changed (shouldn’t affect workflows)
For CI/CD
Section titled “For CI/CD”- New Workflow -
version-aware-build.ymlreplacesci-cd-pipeline.yml - Docker Tags - Semantic versions (1.2.3) instead of git-based (staging-abc123)
- Conditional Builds - Only changed services built (faster, more efficient)
Expected Benefits
Section titled “Expected Benefits”CI/CD Efficiency
Section titled “CI/CD Efficiency”- Before: ~15 minutes to build all 5 services
- After: ~5-10 minutes to build 1-2 changed services
- Savings: 50-75% reduction in build time
Developer Experience
Section titled “Developer Experience”- Automated Changelogs - No manual CHANGELOG.md updates
- Clear Versioning - Semantic versions convey change magnitude
- Enforced Documentation - Pre-commit hook ensures change tracking
Operational
Section titled “Operational”- Selective Deployments - Only deploy what changed
- Version Traceability - Clear mapping of version → changes
- Faster Releases - Automated version bumping and changelog generation
Testing Checklist
Section titled “Testing Checklist”Before considering migration complete, verify:
- Changeset creation works (
pnpm changeset) - Pre-commit hook blocks commits without changeset
- Pre-commit hook allows bypass with
--no-verify - PR builds detect changed apps correctly
- PR builds tag images with
pr-{sha}format - Staging builds use semantic versions from changesets
- Only changed services build on staging
- Staging deployments work correctly
- Release workflow creates “Version Packages” PR on main
- Production builds use correct semantic versions
- Production deployments work correctly
Rollback Instructions
Section titled “Rollback Instructions”If issues arise, follow these steps:
1. Quick Rollback (Restore Old CI/CD)
Section titled “1. Quick Rollback (Restore Old CI/CD)”# Restore old pipelinemv .github/workflows/ci-cd-pipeline-legacy.yml .github/workflows/ci-cd-pipeline.ymlmv .github/workflows/version-aware-build.yml .github/workflows/version-aware-build-disabled.yml
# Disable pre-commit hookmv .husky/pre-commit .husky/pre-commit.disabled
# Commit and pushgit add .github/workflows/ .husky/git commit -m "rollback: restore legacy CI/CD pipeline"git push2. Full Rollback (Remove All Changes)
Section titled “2. Full Rollback (Remove All Changes)”The migration is complete; this rollback plan is retained for historical reference.
Next Steps
Section titled “Next Steps”Immediate (Testing Phase)
Section titled “Immediate (Testing Phase)”- Create test PR with changeset on staging
- Verify build and deployment workflow
- Document any issues or improvements
Short-term (Week 1-2)
Section titled “Short-term (Week 1-2)”- Train team on changeset workflow
- Monitor CI/CD performance metrics
- Gather team feedback
- Make adjustments as needed
Medium-term (Week 3-4)
Section titled “Medium-term (Week 3-4)”- Deploy to production after successful staging testing
- Remove legacy CI/CD pipeline
- Update all repository documentation
- Establish changeset best practices
Long-term (Month 2+)
Section titled “Long-term (Month 2+)”- Review changelog quality
- Optimize version bump strategy
- Consider automated semantic release
- Evaluate additional automation opportunities
Support and Resources
Section titled “Support and Resources”Getting Help
Section titled “Getting Help”- Check Releasing Guide for usage questions
- Review Changesets Documentation for migration questions
- Ask in team channels or create repository issues
Key Concepts
Section titled “Key Concepts”- Changeset - A file describing changes to one or more packages
- Semantic Versioning - Version format MAJOR.MINOR.PATCH (1.2.3)
- Version Bump - Incrementing version based on change type
- Changelog - Auto-generated list of changes per version
Common Issues
Section titled “Common Issues”“No packages selected” error
- Ensure changes are in
apps/orpackages/directories - Check that package has
private: falsein package.json
Pre-commit hook blocking commit
- Run
pnpm changesetto create changeset - Or skip with
git commit --no-verify(use sparingly)
Changeset not detected in CI
- Ensure changeset file is committed and pushed
- Check
.changeset/directory contains .md files
Docker build not triggered
- Verify changeset exists for the specific service
- Check GitHub Actions logs for version detection output
Success Metrics
Section titled “Success Metrics”Track these to measure implementation success:
Technical Metrics
Section titled “Technical Metrics”- CI/CD build time reduced by 50%+
- Only changed services built per commit
- 100% of releases have proper semantic versions
- Zero manual changelog updates needed
Process Metrics
Section titled “Process Metrics”- 100% changeset compliance (via pre-commit hook)
- < 2 minutes to create changeset
- < 5% pre-commit hook bypasses
- Zero version-related deployment issues
Team Metrics
Section titled “Team Metrics”- All developers trained on changeset workflow
- Positive team feedback on new process
- Reduced time spent on release management
- Improved changelog quality
Additional Notes
Section titled “Additional Notes”Python Services (pdf-api, pdf-worker)
Section titled “Python Services (pdf-api, pdf-worker)”The Python services now have package.json files to enable Changesets tracking. The version script updates the version in pyproject.toml when changesets are applied:
# When changeset version is run, it also updates:apps/pdf-api/pyproject.toml - [project] version fieldapps/pdf-worker/pyproject.toml - [project] version fieldDocker Image Versioning
Section titled “Docker Image Versioning”Docker images now use semantic versions:
Before:
ghcr.io/dboone31/erp-unlocked/webapp:staging-a1b2c3dghcr.io/dboone31/erp-unlocked/webapp:main-b4c5d6eAfter:
ghcr.io/dboone31/erp-unlocked/webapp:1.2.3ghcr.io/dboone31/erp-unlocked/webapp:latestghcr.io/dboone31/erp-unlocked/webapp:pr-a1b2c3d (for PRs)Workspace Configuration
Section titled “Workspace Configuration”The workspace is now configured to track 5 versioned applications:
@erp-unlocked/webapp- Main customer application@erp-unlocked/crm- CRM application@erp-unlocked/marketing- Marketing website@erp-unlocked/pdf-api- PDF processing API@erp-unlocked/pdf-worker- PDF processing worker
Shared packages (@repo/*) are ignored from versioning as specified in .changeset/config.json.
Implementation Date: 2025-10-11
Status: ✅ Complete - Ready for Testing
Next Review: After staging deployment testing
Maintainers: Development Team