|
| 1 | +# Semantic-Release Fix Summary |
| 2 | + |
| 3 | +## 🎯 Root Cause Identified |
| 4 | + |
| 5 | +Semantic-release was not triggering releases because `.releaserc.json` was **missing explicit `releaseRules`** in the `@semantic-release/commit-analyzer` plugin configuration. |
| 6 | + |
| 7 | +## 🔍 The Problem |
| 8 | + |
| 9 | +### What We Thought |
| 10 | + |
| 11 | +Initially thought the issue was: |
| 12 | +1. ❌ Merge commit format (partially true) |
| 13 | +2. ❌ Not on main branch (was also an issue initially) |
| 14 | +3. ❌ Squash merge not configured (process issue, not root cause) |
| 15 | + |
| 16 | +### The Real Root Cause |
| 17 | + |
| 18 | +**The `presetConfig.types` configuration only controls CHANGELOG visibility (`hidden` property), NOT what triggers releases!** |
| 19 | + |
| 20 | +```json |
| 21 | +// This ONLY affects changelog, NOT releases: |
| 22 | +"presetConfig": { |
| 23 | + "types": [ |
| 24 | + { "type": "docs", "section": "Documentation", "hidden": false } |
| 25 | + ] |
| 26 | +} |
| 27 | +``` |
| 28 | + |
| 29 | +Without explicit `releaseRules`, semantic-release uses **default rules**: |
| 30 | +- `feat:` → minor release ✅ |
| 31 | +- `fix:` → patch release ✅ |
| 32 | +- Everything else → **NO RELEASE** ❌ |
| 33 | + |
| 34 | +This meant `docs`, `security`, `perf`, and `refactor` commits were **formatted correctly but ignored** for release purposes. |
| 35 | + |
| 36 | +## ✅ The Solution |
| 37 | + |
| 38 | +Added explicit `releaseRules` to `@semantic-release/commit-analyzer`: |
| 39 | + |
| 40 | +```json |
| 41 | +"plugins": [ |
| 42 | + [ |
| 43 | + "@semantic-release/commit-analyzer", |
| 44 | + { |
| 45 | + "preset": "conventionalcommits", |
| 46 | + "releaseRules": [ |
| 47 | + { "type": "feat", "release": "minor" }, |
| 48 | + { "type": "fix", "release": "patch" }, |
| 49 | + { "type": "security", "release": "patch" }, // NEW |
| 50 | + { "type": "perf", "release": "patch" }, // NEW |
| 51 | + { "type": "docs", "release": "patch" }, // NEW |
| 52 | + { "type": "refactor", "release": "patch" }, // NEW |
| 53 | + { "type": "revert", "release": "patch" }, // NEW |
| 54 | + { "type": "style", "release": false }, // NEW |
| 55 | + { "type": "chore", "release": false" }, // NEW |
| 56 | + { "type": "test", "release": false }, // NEW |
| 57 | + { "type": "build", "release": false }, // NEW |
| 58 | + { "type": "ci", "release": false } // NEW |
| 59 | + ] |
| 60 | + } |
| 61 | + ] |
| 62 | +] |
| 63 | +``` |
| 64 | + |
| 65 | +## 📊 Commit Types That Now Trigger Releases |
| 66 | + |
| 67 | +| Type | Release Type | Example | |
| 68 | +|------|-------------|---------| |
| 69 | +| `feat` | Minor (0.X.0) | `feat(atlas): add VPC endpoints` | |
| 70 | +| `fix` | Patch (0.0.X) | `fix(database): correct pagination` | |
| 71 | +| `security` | Patch (0.0.X) | `security: add credential masking` | |
| 72 | +| `perf` | Patch (0.0.X) | `perf(logging): pre-compile regex` | |
| 73 | +| `docs` | Patch (0.0.X) | `docs: update installation guide` | |
| 74 | +| `refactor` | Patch (0.0.X) | `refactor(api): simplify handlers` | |
| 75 | +| `revert` | Patch (0.0.X) | `revert: undo previous change` | |
| 76 | + |
| 77 | +## 📊 Commit Types That DON'T Trigger Releases |
| 78 | + |
| 79 | +| Type | Release | Example | |
| 80 | +|------|---------|---------| |
| 81 | +| `style` | None | `style: fix formatting` | |
| 82 | +| `chore` | None | `chore: update gitignore` | |
| 83 | +| `test` | None | `test: add unit tests` | |
| 84 | +| `build` | None | `build: update dependencies` | |
| 85 | +| `ci` | None | `ci: update workflow` | |
| 86 | + |
| 87 | +## 🔧 Commits Made to Fix |
| 88 | + |
| 89 | +### 1. Commit `b57ac9a` - Initial Fix |
| 90 | +``` |
| 91 | +fix(ci): add releaseRules to commit-analyzer to trigger releases for docs commits |
| 92 | +``` |
| 93 | +- Added releaseRules for docs, perf, refactor, revert |
| 94 | +- Fixed the immediate issue preventing docs commits from triggering releases |
| 95 | + |
| 96 | +### 2. Commit `32b1931` - Complete Fix |
| 97 | +``` |
| 98 | +fix(ci): add security type and explicit release rules for all commit types |
| 99 | +``` |
| 100 | +- Added `security` commit type (used in PR #13) |
| 101 | +- Added explicit `release: false` for non-releasing types |
| 102 | +- Updated PR template with security option |
| 103 | +- Updated CONTRIBUTING.md documentation |
| 104 | + |
| 105 | +## 📝 Commits Since Last Release (v4.0.0) |
| 106 | + |
| 107 | +Now semantic-release will analyze: |
| 108 | + |
| 109 | +``` |
| 110 | +32b1931 fix(ci): add security type and explicit release rules... ✅ PATCH |
| 111 | +b57ac9a fix(ci): add releaseRules to commit-analyzer... ✅ PATCH |
| 112 | +60e7b56 docs: add squash merge setup guide... ✅ PATCH |
| 113 | +c1e06aa docs(ci): enforce squash merge... ✅ PATCH |
| 114 | +5c2afcb Fix/security patches (#13) ❌ INVALID (ignored) |
| 115 | +------- v4.0.0 (last release) |
| 116 | +``` |
| 117 | + |
| 118 | +**Result**: Should trigger **v4.0.1** patch release with 4 valid commits in changelog. |
| 119 | + |
| 120 | +## 🎉 Expected Release |
| 121 | + |
| 122 | +After push to main, semantic-release will: |
| 123 | + |
| 124 | +1. **Analyze commits** since v4.0.0 |
| 125 | +2. **Find valid releases**: |
| 126 | + - 2x `fix(ci):` commits → patch release |
| 127 | + - 2x `docs:` commits → patch release (now recognized!) |
| 128 | +3. **Determine version**: v4.0.1 (patch bump) |
| 129 | +4. **Generate changelog**: |
| 130 | + - Bug Fixes section (2 CI fixes) |
| 131 | + - Documentation section (2 docs updates) |
| 132 | +5. **Create GitHub release** with binaries attached |
| 133 | + |
| 134 | +## 📚 Documentation Updates |
| 135 | + |
| 136 | +### Files Updated |
| 137 | + |
| 138 | +1. **`.releaserc.json`** - Added complete releaseRules |
| 139 | +2. **`.github/CONTRIBUTING.md`** - Added security type to table |
| 140 | +3. **`.github/pull_request_template.md`** - Added security checkbox |
| 141 | +4. **`tracking/documentation.md`** - Tracked this work (TODO) |
| 142 | + |
| 143 | +### Process Improvements |
| 144 | + |
| 145 | +1. **Squash merge enforced** - GitHub configured, PR template guides contributors |
| 146 | +2. **Explicit release rules** - No ambiguity about what triggers releases |
| 147 | +3. **Security commit type** - Now officially supported |
| 148 | +4. **Complete documentation** - CONTRIBUTING.md has full commit type table |
| 149 | + |
| 150 | +## 🚀 Verification Steps |
| 151 | + |
| 152 | +1. **Check GitHub Actions**: https://github.com/teabranch/matlas-cli/actions |
| 153 | +2. **Look for Release workflow** triggered by the push |
| 154 | +3. **Check semantic-release logs** for: |
| 155 | + ``` |
| 156 | + [semantic-release] [@semantic-release/commit-analyzer] › ℹ Analyzing commit: fix(ci)... |
| 157 | + [semantic-release] [@semantic-release/commit-analyzer] › ℹ The release type for the commit is patch |
| 158 | + [semantic-release] › ℹ The next release version is 4.0.1 |
| 159 | + ``` |
| 160 | +4. **Verify new release created**: https://github.com/teabranch/matlas-cli/releases |
| 161 | + |
| 162 | +## 💡 Key Learnings |
| 163 | + |
| 164 | +1. **`presetConfig.types` ≠ `releaseRules`** |
| 165 | + - `presetConfig.types` only controls changelog sections |
| 166 | + - `releaseRules` controls what triggers releases |
| 167 | + |
| 168 | +2. **Always use explicit releaseRules** |
| 169 | + - Don't rely on preset defaults |
| 170 | + - Make release behavior explicit and documented |
| 171 | + |
| 172 | +3. **Squash merge is a process issue** |
| 173 | + - It helps ensure clean commit messages |
| 174 | + - But doesn't fix underlying configuration issues |
| 175 | + - Both are needed: proper config + proper process |
| 176 | + |
| 177 | +4. **Security is a valid commit type** |
| 178 | + - Though not in standard Conventional Commits spec |
| 179 | + - Many projects use it for security-related changes |
| 180 | + - Now properly configured and documented |
| 181 | + |
| 182 | +## 📖 References |
| 183 | + |
| 184 | +- [Conventional Commits Specification](https://www.conventionalcommits.org/) |
| 185 | +- [semantic-release Documentation](https://semantic-release.gitbook.io/) |
| 186 | +- [commit-analyzer Plugin](https://github.com/semantic-release/commit-analyzer) |
| 187 | +- [conventionalcommits Preset](https://github.com/conventional-changelog/conventional-changelog/tree/master/packages/conventional-changelog-conventionalcommits) |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +**Status**: ✅ Fixed and pushed to main |
| 192 | +**Expected Release**: v4.0.1 (patch) |
| 193 | +**Next Steps**: Monitor GitHub Actions for release creation |
0 commit comments