Developer Workflow with Changesets
This guide explains how to use changesets for version management and changelog generation in the ERP-Unlocked monorepo.
Table of Contents
Section titled “Table of Contents”- Overview
- Making Changes
- Creating a Changeset
- Checking Release Status
- Version Types
- Release Process
- Pre-commit Hook
- Troubleshooting
Overview
Section titled “Overview”ERP-Unlocked uses Changesets to manage versions and changelogs across the monorepo. Each time you make a change to any app or package, you create a changeset that describes what changed and what type of change it is (major, minor, or patch).
Making Changes
Section titled “Making Changes”The typical workflow for making changes:
- Create a new branch for your feature/fix
- Make your code changes
- Before committing: Create a changeset
- Commit both your changes and the changeset file
- Push and create a pull request
Creating a Changeset
Section titled “Creating a Changeset”Step 1: Run the changeset command
Section titled “Step 1: Run the changeset command”After making your code changes, run:
pnpm changesetStep 2: Select affected packages
Section titled “Step 2: Select affected packages”The CLI will prompt you to select which packages have changed. Use the arrow keys and spacebar to select:
@erp-unlocked/webapp- Main customer application@erp-unlocked/internal- Internal admin application@erp-unlocked/email-worker- Inbound email worker@erp-unlocked/pdf-api- PDF processing API@erp-unlocked/pdf-worker- PDF processing worker
Step 3: Choose the version bump type
Section titled “Step 3: Choose the version bump type”For each selected package, choose the type of change:
- patch - Bug fixes and minor changes (0.1.0 → 0.1.1)
- minor - New features, backward compatible (0.1.0 → 0.2.0)
- major - Breaking changes (0.1.0 → 1.0.0)
Step 4: Write a summary
Section titled “Step 4: Write a summary”Provide a clear, concise summary of the changes. This will appear in the changelog:
Good Examples:
Fixed order validation to properly handle decimal quantitiesAdded support for custom tax rates in the order editorBREAKING: Removed support for legacy CSV formatBad Examples:
Fixed bugUpdated codeStep 5: Commit the changeset
Section titled “Step 5: Commit the changeset”The changeset will be saved to .changeset/random-words-here.md. Commit this file along with your code changes:
git add .changeset/random-words-here.mdgit commit -m "feat: add custom tax rates support"Checking Status
Section titled “Checking Status”View pending releases
Section titled “View pending releases”See what would be released based on current changesets:
pnpm version:checkDetailed view of pending releases
Section titled “Detailed view of pending releases”For more detailed information about what will change:
pnpm version:previewCheck if changesets exist
Section titled “Check if changesets exist”Verify that all necessary changesets are present:
pnpm changeset:statusVersion Types
Section titled “Version Types”Changesets uses Semantic Versioning (SemVer):
Patch (0.1.0 → 0.1.1)
Section titled “Patch (0.1.0 → 0.1.1)”Use for:
- Bug fixes
- Documentation updates
- Internal refactoring
- Performance improvements
Example:
# Select: patch# Summary: Fixed PDF extraction error for invoices with special charactersMinor (0.1.0 → 0.2.0)
Section titled “Minor (0.1.0 → 0.2.0)”Use for:
- New features
- New API endpoints
- Backward-compatible functionality additions
- UI enhancements
Example:
# Select: minor# Summary: Added bulk order import feature with CSV uploadMajor (0.1.0 → 1.0.0)
Section titled “Major (0.1.0 → 1.0.0)”Use for:
- Breaking changes
- API changes that require client updates
- Removal of deprecated features
- Database schema changes
Example:
# Select: major# Summary: BREAKING: Changed authentication to require organization contextRelease Process (Maintainers Only)
Section titled “Release Process (Maintainers Only)”Automated Release Flow
Section titled “Automated Release Flow”The repository uses a hybrid release strategy that balances speed and safety:
Staging Branch (Fully Automated)
Section titled “Staging Branch (Fully Automated)”- When changes with changesets are pushed to
staging release.ymlcreates a “Version Packages” PR- The PR is automatically merged when all CI checks pass
- Services are automatically deployed to staging
Timeline: ~10-15 minutes from push to deployment
This approach enables fast iteration and testing without manual intervention.
Main Branch (Manual Review)
Section titled “Main Branch (Manual Review)”- When changes with changesets are pushed to
main release.ymlcreates a “Version Packages” PR- Maintainer manually reviews and merges the PR
- Services are automatically deployed to production
Timeline: Controlled by maintainer approval
This approach ensures production releases are intentional and reviewed.
How It Works
Section titled “How It Works”Releases are automatically managed by GitHub Actions:
- The
release.ymlworkflow detects pending changesets - Creates a “Version Packages” pull request
- When the PR is merged:
- Updates package versions
- Generates CHANGELOGs
- Triggers Docker builds with semantic versions
- Deploys to appropriate environment
Manual Release
Section titled “Manual Release”If needed, maintainers can manually trigger releases:
# Step 1: Update versions based on changesetspnpm version:apply
# Step 2: Install updated dependenciespnpm install
# Step 3: Build all packagespnpm build
# Step 4: Commit version changesgit add .git commit -m "chore: version packages"git push
# Step 5: Publish (handled by CI/CD)Pre-commit Hook
Section titled “Pre-commit Hook”The repository has a pre-commit hook that enforces changeset creation. If you try to commit changes to apps/ or packages/ without a changeset, you’ll see:
⚠️ Changes detected to apps/ or packages/ but no changeset found.
Please run: pnpm changesetThen commit the generated changeset file.Or skip with: git commit --no-verifySkipping the hook
Section titled “Skipping the hook”In rare cases where a changeset is not needed (e.g., CI config changes), you can skip the hook:
git commit --no-verify -m "ci: update workflow configuration"Note: Use --no-verify sparingly. Most code changes should have a changeset.
Troubleshooting
Section titled “Troubleshooting””No packages selected” error
Section titled “”No packages selected” error”Make sure you’ve made changes to files in apps/ or packages/ directories. Changesets only tracks versioned packages.
Changeset file conflicts
Section titled “Changeset file conflicts”If multiple developers create changesets simultaneously, you may encounter conflicts in changeset files. To resolve:
- Keep both changeset files (they have unique names)
- Don’t try to merge the content
- Both changesets will be processed during release
Pre-commit hook issues
Section titled “Pre-commit hook issues”If the pre-commit hook is not working:
# Reinstall hookspnpm prepareChangeset not detected in CI
Section titled “Changeset not detected in CI”Ensure the changeset file is committed and pushed:
git statusgit add .changeset/*.mdgit commit -m "chore: add changeset"git pushDocker Image Versioning
Section titled “Docker Image Versioning”When you create a changeset, the version bump will be used for Docker image tags:
- Development/PRs: Images tagged with
pr-{commit-sha}(e.g.,pr-a1b2c3d) - Staging/Main: Images tagged with semantic version (e.g.,
1.2.3)
Only services with changesets will have new Docker images built and deployed.
Examples
Section titled “Examples”Example 1: Bug Fix in Webapp
Section titled “Example 1: Bug Fix in Webapp”# 1. Make the fix# 2. Create changesetpnpm changeset# Select: @erp-unlocked/webapp# Type: patch# Summary: Fixed date formatting in order history
# 3. Commitgit add .git commit -m "fix: correct date formatting in order history"git pushExample 2: New Feature Across Multiple Apps
Section titled “Example 2: New Feature Across Multiple Apps”# 1. Implement feature in webapp and crm# 2. Create changesetpnpm changeset# Select: @erp-unlocked/webapp, @erp-unlocked/crm# Type: minor for both# Summary: Added real-time order status updates with WebSocket support
# 3. Commitgit add .git commit -m "feat: add real-time order status updates"git pushExample 3: Breaking Change in PDF API
Section titled “Example 3: Breaking Change in PDF API”# 1. Make breaking changes to API# 2. Create changesetpnpm changeset# Select: @erp-unlocked/pdf-api# Type: major# Summary: BREAKING: Changed /extract endpoint to require API version header
# 3. Commitgit add .git commit -m "feat!: require API version in pdf-api endpoints"git pushBest Practices
Section titled “Best Practices”- One changeset per logical change - Don’t combine unrelated changes
- Write clear summaries - They become your changelog
- Use conventional commit messages - Helps with PR organization
- Create changesets early - Don’t wait until the PR is ready
- Review changesets in PRs - Ensure accuracy before merging
- Keep changesets focused - Smaller, focused changes are easier to review
Additional Resources
Section titled “Additional Resources”For questions or issues with the changeset workflow, please reach out to the maintainers or create an issue in the repository.