|
| 1 | +# 🚀 Migration Guide: Gitflow → Trunk-Based Development |
| 2 | + |
| 3 | +## 📌 Summary of Changes |
| 4 | + |
| 5 | +ApexStore has migrated from **Gitflow** (with `develop`, `release/*`, `hotfix/*` branches) to **trunk-based development** with direct merges to `main`. |
| 6 | + |
| 7 | +### Before (Gitflow) |
| 8 | +``` |
| 9 | +feature/* → develop → release/* → main → manual tag + release |
| 10 | +``` |
| 11 | + |
| 12 | +### After (Trunk-Based) |
| 13 | +``` |
| 14 | +feature/* → main → auto version bump + tag + release |
| 15 | +``` |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## ✅ What Changed |
| 20 | + |
| 21 | +| Aspect | Old (Gitflow) | New (Trunk-Based) | |
| 22 | +|--------|---------------|-------------------| |
| 23 | +| **Main branch** | `main` (stable releases only) | `main` (always deployable) | |
| 24 | +| **Development branch** | `develop` | ❌ Removed | |
| 25 | +| **Feature branches** | `feature/*` → `develop` | `feat/*` / `fix/*` → `main` | |
| 26 | +| **Release process** | Manual `release/*` branches | ✅ Automatic on merge | |
| 27 | +| **Version bumping** | Manual in `Cargo.toml` | ✅ Auto-increment patch | |
| 28 | +| **Tagging** | Manual `git tag vX.Y.Z` | ✅ Auto-created | |
| 29 | +| **GitHub Release** | Manual creation | ✅ Auto-generated with notes | |
| 30 | +| **CI checks** | Multiple workflows | 1 unified `pr-validation.yml` | |
| 31 | + |
| 32 | +--- |
| 33 | + |
| 34 | +## 🛠️ New Workflow (Step-by-Step) |
| 35 | + |
| 36 | +### 1. Creating a Feature |
| 37 | + |
| 38 | +```bash |
| 39 | +# Start from main (always up-to-date) |
| 40 | +git checkout main |
| 41 | +git pull origin main |
| 42 | + |
| 43 | +# Create feature branch |
| 44 | +git checkout -b feat/my-awesome-feature |
| 45 | +# or |
| 46 | +git checkout -b fix/critical-bug |
| 47 | +``` |
| 48 | + |
| 49 | +### 2. Development & Commits |
| 50 | + |
| 51 | +```bash |
| 52 | +# Make changes |
| 53 | +vim src/core/engine.rs |
| 54 | + |
| 55 | +# Commit with conventional commits |
| 56 | +git add . |
| 57 | +git commit -m "feat: add caching layer to engine" |
| 58 | +# or |
| 59 | +git commit -m "fix: resolve memory leak in SSTable reader" |
| 60 | + |
| 61 | +# Push to remote |
| 62 | +git push origin feat/my-awesome-feature |
| 63 | +``` |
| 64 | + |
| 65 | +### 3. Open Pull Request |
| 66 | + |
| 67 | +1. Go to GitHub and open a PR from `feat/my-awesome-feature` → `main` |
| 68 | +2. **CI automatically runs** (`pr-validation.yml`): |
| 69 | + - `cargo fmt --check` |
| 70 | + - `cargo clippy -- -D warnings` |
| 71 | + - `cargo test --all-features` |
| 72 | + - `cargo build --release` |
| 73 | +3. Fix any CI failures |
| 74 | +4. Request code review |
| 75 | +5. Address review comments |
| 76 | + |
| 77 | +### 4. Merge to Main |
| 78 | + |
| 79 | +1. Once approved, click **"Merge Pull Request"** |
| 80 | +2. **CI automatically runs** (`release.yml`): |
| 81 | + - Version bumps: `2.1.0` → `2.1.1` |
| 82 | + - Commits: `chore: bump version to 2.1.1 [skip ci]` |
| 83 | + - Creates tag: `v2.1.1` |
| 84 | + - Creates GitHub Release with changelog |
| 85 | +3. **Done!** Your feature is released 🎉 |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## ⚠️ Breaking Changes & Cleanup |
| 90 | + |
| 91 | +### Branches to Delete |
| 92 | + |
| 93 | +After merging this migration PR, delete the following branches: |
| 94 | + |
| 95 | +```bash |
| 96 | +git push origin --delete develop # No longer used |
| 97 | +git push origin --delete release/* # No longer used |
| 98 | +``` |
| 99 | + |
| 100 | +### Local Cleanup |
| 101 | + |
| 102 | +```bash |
| 103 | +# Remove local references to deleted branches |
| 104 | +git fetch --prune |
| 105 | + |
| 106 | +# Delete local develop branch |
| 107 | +git branch -D develop |
| 108 | + |
| 109 | +# Set main as default tracking branch |
| 110 | +git branch --set-upstream-to=origin/main main |
| 111 | +``` |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +## 📚 FAQ |
| 116 | + |
| 117 | +### Q: What if I need a **minor** or **major** version bump? |
| 118 | + |
| 119 | +**A:** The CI auto-increments **patch** by default. For minor/major: |
| 120 | + |
| 121 | +```bash |
| 122 | +# Option 1: Manually edit Cargo.toml in your PR |
| 123 | +vim Cargo.toml |
| 124 | +# Change: version = "2.1.0" → "2.2.0" (minor) or "3.0.0" (major) |
| 125 | + |
| 126 | +# Option 2: Use cargo-bump (if installed) |
| 127 | +cargo install cargo-bump |
| 128 | +cargo bump minor # or: cargo bump major |
| 129 | +``` |
| 130 | + |
| 131 | +Then open PR as usual. The CI will detect the manually set version and **not** override it. |
| 132 | + |
| 133 | +### Q: How do I create a **hotfix** for production? |
| 134 | + |
| 135 | +**A:** Same as a feature: |
| 136 | + |
| 137 | +```bash |
| 138 | +git checkout main |
| 139 | +git pull |
| 140 | +git checkout -b fix/critical-security-issue |
| 141 | +# ... make fix ... |
| 142 | +git commit -m "fix: patch XSS vulnerability in API" |
| 143 | +git push origin fix/critical-security-issue |
| 144 | +# Open PR → main, merge, auto-release! |
| 145 | +``` |
| 146 | + |
| 147 | +### Q: What if CI fails on my PR? |
| 148 | + |
| 149 | +**A:** Fix the issues locally: |
| 150 | + |
| 151 | +```bash |
| 152 | +# Check format |
| 153 | +cargo fmt |
| 154 | + |
| 155 | +# Fix clippy warnings |
| 156 | +cargo clippy --fix --allow-dirty |
| 157 | + |
| 158 | +# Run tests |
| 159 | +cargo test |
| 160 | + |
| 161 | +# Commit fixes |
| 162 | +git add . |
| 163 | +git commit -m "chore: fix CI issues" |
| 164 | +git push |
| 165 | +``` |
| 166 | + |
| 167 | +CI will re-run automatically. |
| 168 | + |
| 169 | +### Q: Can I still manually create releases? |
| 170 | + |
| 171 | +**A:** Yes, but not recommended. The CI handles it better. If needed: |
| 172 | + |
| 173 | +```bash |
| 174 | +# Disable the release.yml workflow temporarily |
| 175 | +# Then follow manual steps |
| 176 | +``` |
| 177 | + |
| 178 | +### Q: What about `develop` branch history? |
| 179 | + |
| 180 | +**A:** All commits from `develop` should be merged to `main` before deleting it: |
| 181 | + |
| 182 | +```bash |
| 183 | +# If develop has unmerged commits: |
| 184 | +git checkout main |
| 185 | +git merge develop |
| 186 | +git push origin main |
| 187 | + |
| 188 | +# Then delete develop |
| 189 | +git push origin --delete develop |
| 190 | +``` |
| 191 | + |
| 192 | +--- |
| 193 | + |
| 194 | +## 👥 Team Onboarding Checklist |
| 195 | + |
| 196 | +- [ ] Read this migration guide |
| 197 | +- [ ] Delete local `develop` branch |
| 198 | +- [ ] Update Git remote tracking: `git fetch --prune` |
| 199 | +- [ ] Read `.github/workflows/README.md` |
| 200 | +- [ ] Test workflow: create a small PR, merge, verify auto-release |
| 201 | +- [ ] Update any CI/CD documentation in wikis/Notion/etc. |
| 202 | +- [ ] Notify team of new workflow in Slack/Discord |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +## 📞 Support |
| 207 | + |
| 208 | +Questions? Open an issue labeled `workflow` or ping @ElioNeto. |
| 209 | + |
| 210 | +--- |
| 211 | + |
| 212 | +**Migration Date:** March 9, 2026 |
| 213 | +**Migrated By:** github-actions[bot] / Elio Neto |
0 commit comments