$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill semantic-versioningAutomate versioning and changelog generation using semantic versioning principles. Configure release automation, version bumping, and changelog tools. Use when implementing version management or automating release processes.
| 1 | # Semantic Versioning |
| 2 | |
| 3 | Automate version management and changelog generation following SemVer principles. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Implementing version numbering standards |
| 9 | - Automating release versioning |
| 10 | - Generating changelogs automatically |
| 11 | - Setting up release pipelines |
| 12 | - Managing package versions |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | - Git repository with commit history |
| 17 | - Node.js (for most tools) |
| 18 | - Conventional commits (recommended) |
| 19 | |
| 20 | ## Semantic Versioning Basics |
| 21 | |
| 22 | ### Version Format |
| 23 | |
| 24 | ``` |
| 25 | MAJOR.MINOR.PATCH[-PRERELEASE][+BUILD] |
| 26 | |
| 27 | Examples: |
| 28 | 1.0.0 |
| 29 | 2.1.3 |
| 30 | 1.0.0-alpha.1 |
| 31 | 1.0.0-beta.2+build.123 |
| 32 | ``` |
| 33 | |
| 34 | ### Version Components |
| 35 | |
| 36 | | Component | When to Increment | |
| 37 | |-----------|-------------------| |
| 38 | | MAJOR | Breaking changes (incompatible API changes) | |
| 39 | | MINOR | New features (backward compatible) | |
| 40 | | PATCH | Bug fixes (backward compatible) | |
| 41 | | PRERELEASE | Pre-release versions (alpha, beta, rc) | |
| 42 | | BUILD | Build metadata (ignored in precedence) | |
| 43 | |
| 44 | ### Version Precedence |
| 45 | |
| 46 | ``` |
| 47 | 1.0.0-alpha < 1.0.0-alpha.1 < 1.0.0-alpha.beta |
| 48 | < 1.0.0-beta < 1.0.0-beta.2 < 1.0.0-beta.11 |
| 49 | < 1.0.0-rc.1 < 1.0.0 < 2.0.0 |
| 50 | ``` |
| 51 | |
| 52 | ## Conventional Commits to Version |
| 53 | |
| 54 | ```yaml |
| 55 | Commit Type → Version Bump: |
| 56 | feat: → MINOR |
| 57 | fix: → PATCH |
| 58 | docs: → PATCH (or no release) |
| 59 | style: → PATCH (or no release) |
| 60 | refactor: → PATCH |
| 61 | perf: → PATCH |
| 62 | test: → No release |
| 63 | chore: → No release |
| 64 | |
| 65 | BREAKING CHANGE: → MAJOR |
| 66 | feat!: → MAJOR |
| 67 | fix!: → MAJOR |
| 68 | ``` |
| 69 | |
| 70 | ## semantic-release |
| 71 | |
| 72 | ### Installation |
| 73 | |
| 74 | ```bash |
| 75 | npm install --save-dev semantic-release \ |
| 76 | @semantic-release/changelog \ |
| 77 | @semantic-release/git |
| 78 | ``` |
| 79 | |
| 80 | ### Configuration |
| 81 | |
| 82 | ```json |
| 83 | // .releaserc.json |
| 84 | { |
| 85 | "branches": ["main"], |
| 86 | "plugins": [ |
| 87 | "@semantic-release/commit-analyzer", |
| 88 | "@semantic-release/release-notes-generator", |
| 89 | ["@semantic-release/changelog", { |
| 90 | "changelogFile": "CHANGELOG.md" |
| 91 | }], |
| 92 | ["@semantic-release/npm", { |
| 93 | "npmPublish": true |
| 94 | }], |
| 95 | ["@semantic-release/git", { |
| 96 | "assets": ["CHANGELOG.md", "package.json", "package-lock.json"], |
| 97 | "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" |
| 98 | }], |
| 99 | "@semantic-release/github" |
| 100 | ] |
| 101 | } |
| 102 | ``` |
| 103 | |
| 104 | ### Advanced Configuration |
| 105 | |
| 106 | ```javascript |
| 107 | // release.config.js |
| 108 | module.exports = { |
| 109 | branches: [ |
| 110 | 'main', |
| 111 | { name: 'beta', prerelease: true }, |
| 112 | { name: 'alpha', prerelease: true } |
| 113 | ], |
| 114 | plugins: [ |
| 115 | ['@semantic-release/commit-analyzer', { |
| 116 | preset: 'angular', |
| 117 | releaseRules: [ |
| 118 | { type: 'docs', release: 'patch' }, |
| 119 | { type: 'refactor', release: 'patch' }, |
| 120 | { type: 'style', release: 'patch' }, |
| 121 | { type: 'perf', release: 'patch' }, |
| 122 | { breaking: true, release: 'major' } |
| 123 | ] |
| 124 | }], |
| 125 | ['@semantic-release/release-notes-generator', { |
| 126 | preset: 'angular', |
| 127 | writerOpts: { |
| 128 | commitsSort: ['subject', 'scope'] |
| 129 | } |
| 130 | }], |
| 131 | '@semantic-release/changelog', |
| 132 | '@semantic-release/npm', |
| 133 | '@semantic-release/git', |
| 134 | '@semantic-release/github' |
| 135 | ] |
| 136 | }; |
| 137 | ``` |
| 138 | |
| 139 | ### GitHub Actions Integration |
| 140 | |
| 141 | ```yaml |
| 142 | # .github/workflows/release.yml |
| 143 | name: Release |
| 144 | |
| 145 | on: |
| 146 | push: |
| 147 | branches: [main] |
| 148 | |
| 149 | jobs: |
| 150 | release: |
| 151 | runs-on: ubuntu-latest |
| 152 | steps: |
| 153 | - uses: actions/checkout@v4 |
| 154 | with: |
| 155 | fetch-depth: 0 |
| 156 | persist-credentials: false |
| 157 | |
| 158 | - uses: actions/setup-node@v4 |
| 159 | with: |
| 160 | node-version: '20' |
| 161 | |
| 162 | - run: npm ci |
| 163 | |
| 164 | - name: Release |
| 165 | env: |
| 166 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 167 | NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 168 | run: npx semantic-release |
| 169 | ``` |
| 170 | |
| 171 | ## standard-version |
| 172 | |
| 173 | ### Installation |
| 174 | |
| 175 | ```bash |
| 176 | npm install --save-dev standard-version |
| 177 | ``` |
| 178 | |
| 179 | ### Configuration |
| 180 | |
| 181 | ```json |
| 182 | // .versionrc.json |
| 183 | { |
| 184 | "types": [ |
| 185 | { "type": "feat", "section": "Features" }, |
| 186 | { "type": "fix", "section": "Bug Fixes" }, |
| 187 | { "type": "docs", "section": "Documentation" }, |
| 188 | { "type": "style", "section": "Styling" }, |
| 189 | { "type": "refactor", "section": "Code Refactoring" }, |
| 190 | { "type": "perf", "section": "Performance" }, |
| 191 | { "type": "test", "section": "Tests" }, |
| 192 | { "type": "chore", "section": "Maintenance" } |
| 193 | ], |
| 194 | "skip": { |
| 195 | "bump": false, |
| 196 | "changelog": false, |
| 197 | "commit": false, |
| 198 | "tag": false |
| 199 | }, |
| 200 | "commitUrlFormat": "https://github.com/owner/repo/commit/{{hash}}", |
| 201 | "compareUrlFormat": "https://github.com/owner/repo/compare/{{previousTag}}...{{currentTag}}" |
| 202 | } |
| 203 | ``` |
| 204 | |
| 205 | ### Usage |
| 206 | |
| 207 | ```bash |
| 208 | # First release |
| 209 | npx standard-version --first-release |
| 210 | |
| 211 | # Regular release (auto-detect version bump) |
| 212 | npx standard-version |
| 213 | |
| 214 | # Specific version bump |
| 215 | npx standard-version --release-as minor |
| 216 | npx standard-version --release-as 1.1.0 |
| 217 | |
| 218 | # Pre-release |
| 219 | npx standard-ver |