Branching and Versioning Strategy
This document outlines the branching model and versioning scheme for the AllMyChats project.
Branching Strategy: GitHub Flow
We use GitHub Flow, a simple and effective branching model ideal for continuous deployment.
Branch Types
1. Main Branch (master)
- Purpose: Production-ready code
- Protection: Protected branch with required reviews
- Deployment: Automatically deploys to production
- Rules:
- No direct commits allowed
- All changes via Pull Requests
- Requires passing CI/CD checks
- Requires at least 1 approval
2. Feature Branches (feature/*)
- Naming:
feature/descriptive-name - Examples:
feature/whatsapp-integrationfeature/user-authenticationfeature/payment-flow
- Lifecycle:
- Branch from
master - Develop and commit changes
- Open PR to
master - Review, test, merge
- Keep (Default)/Delete after merge
- Branch from
- Best Practices:
- Keep branches short-lived (1-3 days ideal)
- Commit often with clear messages
- Sync with
masterregularly - Use conventional commit format
3. Hotfix Branches (hotfix/*)
- Naming:
hotfix/issue-description - Example:
hotfix/payment-webhook-crash - Purpose: Urgent production fixes
- Lifecycle:
- Branch from
master - Fix the issue
- Fast-track PR review
- Merge and deploy immediately
- Delete after merge
- Branch from
Workflow
master (protected)
↓
└─→ feature/new-feature
↓ (develop)
↓ (commit)
↓ (push)
└─→ Pull Request → Review → Merge → Delete
↓
master (deploy)
Versioning Strategy: Semantic Versioning
We follow Semantic Versioning 2.0.0 with named releases.
Version Format
MAJOR.MINOR.PATCH
- MAJOR: Breaking changes (incompatible API changes)
- MINOR: New features (backwards-compatible)
- PATCH: Bug fixes (backwards-compatible)
Examples
0.1.0→0.1.1- Bug fix0.1.1→0.2.0- New feature0.2.0→1.0.0- Breaking change or first stable release
Pre-release Versions
For pre-release versions, append a hyphen and identifier:
1.0.0-alpha.1- Alpha release1.0.0-beta.1- Beta release1.0.0-rc.1- Release candidate
Named Releases
Each major/minor release gets a code name for marketing and communication:
Format: [Version] - "[Descriptive Name]"
Examples:
v1.0.0 - "Genesis"- First stable releasev1.1.0 - "Swift"- Performance improvementsv2.0.0 - "Phoenix"- Major redesign
Naming Guidelines:
- Choose memorable, positive names
- Reflect the release's key theme or feature
- Can use: animals, celestial objects, mythology, nature
- Keep it professional and brand-appropriate
Commit Message Convention
We use Conventional Commits for automated changelog generation.
Format
<type>(<scope>): <subject>
<body>
<footer>
Types
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changes (formatting, no logic change)refactor: Code refactoringperf: Performance improvementstest: Adding or updating testsbuild: Build system or dependency changesci: CI/CD configuration changeschore: Other changes (maintenance)revert: Reverting a previous commit
Examples
feat(auth): add Google OAuth integration
feat(whatsapp): implement message parsing and analysis
- Parse WhatsApp chat exports
- Extract metadata and statistics
- Support multiple chat formats
fix(payment): prevent duplicate subscription charges
fix(ui): correct theme toggle persistence
Closes #123
BREAKING CHANGE: changed authentication API endpoints
Scope Examples
auth- Authenticationpayment- Payment processingui- User interfacedb- Databaseapi- API endpointswhatsapp- WhatsApp integration
Release Process
1. Prepare Release
# Ensure you're on master and up to date
git checkout master
git pull origin master
# Run tests and linting
npm run lint:all
npm test
# Decide version bump (patch/minor/major)
# This will update package.json and create a git tag
npm run release:patch # 0.1.0 → 0.1.1
npm run release:minor # 0.1.0 → 0.2.0
npm run release:major # 0.1.0 → 1.0.0
2. Review and Edit
The release script will:
- Bump version in
package.json - Generate/update
CHANGELOG.md - Create a git tag
- Commit changes
Review the generated changelog and edit if needed.
3. Push Release
# Push commits and tags
git push origin master --follow-tags
4. Create GitHub Release
- Go to GitHub repository
- Click "Releases" → "Draft a new release"
- Select the created tag
- Add release title:
v[VERSION] - "[NAME]" - Copy relevant changelog section
- Mark as pre-release if applicable
- Publish release
5. Deploy
The CI/CD pipeline will automatically deploy to production when the release is published.
Branch Protection Rules
Setting Up Branch Protection on GitHub
After merging this strategy, configure branch protection for master:
Steps:
- Go to GitHub repository Settings
- Navigate to Branches → Add branch protection rule
- Branch name pattern:
master - Enable the following:
- ✅ Require pull request reviews before merging
- Required approvals: 1
- ✅ Require status checks to pass before merging
- Required checks:
lint,type-check,test,build
- Required checks:
- ✅ Require conversation resolution before merging
- ✅ Require linear history (no merge commits)
- ✅ Do not allow bypassing the above settings
- ✅ Require pull request reviews before merging
Best Practices
Branching
- Keep branches focused: One feature/fix per branch
- Update regularly: Sync with
masteroften to avoid conflicts - Delete merged branches: Keep repository clean
- Use descriptive names:
feature/add-user-analyticsnotfeature/updates
Commits
- Commit often: Small, logical commits are easier to review
- Write clear messages: Follow conventional commit format
- Reference issues: Use
Closes #123orFixes #456 - Don't commit secrets: Use environment variables
Pull Requests
- Provide context: Clear title and description
- Keep PRs small: Easier to review and merge
- Request specific reviewers: Get the right eyes on the code
- Respond to feedback: Address comments promptly
- Test before requesting review: Ensure CI passes
Versioning
- Document breaking changes: Always note in BREAKING CHANGE footer
- Follow semver strictly: Don't confuse users with wrong increments
- Test before releasing: Run full test suite
- Write good release notes: Help users understand what changed
Quick Reference
Create Feature Branch
git checkout master
git pull origin master
git checkout -b feature/descriptive-name
Commit Changes
git add .
git commit -m "feat(scope): add new feature"
Open Pull Request
git push origin feature/descriptive-name
# Then open PR on GitHub
Release
# On master branch
npm run release:patch # or minor/major
git push origin master --follow-tags
Tools and Automation
- Husky: Git hooks for pre-commit checks
- Lint-staged: Run linters on staged files
- Conventional Commits: Enforced commit message format
- Standard Version: Automated versioning and changelog
- GitHub Actions: CI/CD automation
Troubleshooting
Commit Message Rejected
Problem: commitlint rejects your commit with error like "type may not be empty"
Solution:
# Check the error message
# Fix your commit message to match conventional format
git commit --amend -m "feat(scope): correct message"
Common errors:
type may not be empty→ Missing type (feat, fix, etc.)type must be lower-case→ Use lowercase (feat not FEAT)subject may not be empty→ Missing description after colon
Failed CI Checks
Problem: GitHub Actions CI checks fail
Solution: Run checks locally before pushing
npm run lint:all # Runs type-check, lint, and format check
npm test # Runs all tests
npm run build # Ensures code builds
Merge Conflicts
Problem: Conflicts when merging or updating branch
Solution: Update your branch with latest master
git checkout master
git pull origin master
git checkout feature/your-branch
git merge master
# Resolve conflicts in your editor
git add .
git commit
Prevention: Regularly sync your feature branch with master to minimize conflicts.
Related Documentation
- Conventional Commits: https://www.conventionalcommits.org/
- Semantic Versioning: https://semver.org/
Questions?
For questions about the branching or versioning strategy, please:
- Check this document first
- Review the Architecture documentation for technical details
- Ask in team chat
- Open a discussion on GitHub
Action Items for Setup
After setting up this strategy, complete the following tasks:
1. Set Up Branch Protection Rules on GitHub
Priority: High Time: 5 minutes
- Go to your GitHub repository
- Click Settings → Branches
- Click Add branch protection rule
- Configure as detailed in Branch Protection Rules section above
- Save the rule
Why: Prevents accidental direct commits to master and enforces code review.
2. Test the Commit Message Validation
Priority: Medium Time: 2 minutes
Try making a test commit to verify commitlint is working:
# This should FAIL
git commit -m "test commit"
# This should SUCCEED
git commit -m "test: verify commitlint setup"
If the first commit succeeds, the git hook may not be installed. Run:
npm install
npx husky install
3. Test the Release Process (Dry Run)
Priority: Medium Time: 3 minutes
Test the release automation without making actual changes:
git checkout master
git pull origin master
npm run release:dry-run
Review the output to ensure it correctly analyzes commits and would generate appropriate changelog entries.
4. Configure GitHub Actions Secrets (If Needed)
Priority: Low Time: 5 minutes
If you plan to use the automated release workflow:
- Go to GitHub repository Settings → Secrets and variables → Actions
- Verify
GITHUB_TOKENis available (it's automatic) - Add any additional secrets needed for deployment
5. Share Documentation with Team
Priority: Low Time: 10 minutes
- Share this branching strategy with your team
- Review the strategy in a team meeting
- Ensure everyone understands conventional commit format
- Consider adding commit message examples to your team wiki
6. Create Your First Release (When Ready)
Priority: Low Time: 10 minutes
When you're ready to create the first official release:
- Ensure all changes are merged to master
- Run
npm run release:minor(to create v0.1.0 or bump to next version) - Review the generated CHANGELOG.md
- Push:
git push origin master --follow-tags - Create a GitHub Release with a named version (e.g., "v0.1.0 - Genesis")
Note: Items 1-3 should be completed immediately after setup. Items 4-6 can be done at your convenience.