Maintenance Branch Configuration for semantic-release
Configure semantic-release to support maintenance branches for backporting fixes to older major versions. Release patches for v1.x while developing v2.x on main.
Detailed Explanation
Maintenance Branches for Legacy Versions
Maintenance branches allow you to continue releasing patches for older major versions while developing new features on the main branch.
Configuration
{
"branches": [
"+([0-9])?(.{+([0-9]),x}).x",
"main",
{"name": "next", "prerelease": true}
],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/npm",
"@semantic-release/github"
]
}
How Maintenance Branches Work
The glob pattern +([0-9])?(.{+([0-9]),x}).x matches branch names like:
| Branch | Versions Released |
|---|---|
1.x |
1.x.x (patches for v1) |
2.x |
2.x.x (patches for v2) |
1.5.x |
1.5.x (patches for v1.5 only) |
main |
Latest major/minor/patch |
Workflow Example
- You're on v2.x (main branch)
- A critical bug is found in v1.x
- Create/checkout the
1.xbranch from the last v1 tag - Cherry-pick or write the fix
- Push to
1.x— semantic-release publishes v1.x.y
Version Range Constraints
semantic-release ensures that maintenance branches never publish versions that overlap with the main branch:
1.xbranch can only publish>=1.0.0 <2.0.0mainbranch publishes>=2.0.0
npm Distribution Tags
Maintenance releases are published under their own dist-tag:
npm install my-package@release-1.x # Latest v1 patch
npm install my-package # Latest (v2+)
Use Case
Libraries with multiple major versions in production where older versions still need security patches and bug fixes. Common for database drivers, HTTP clients, and framework plugins where users can't always upgrade to the latest major version.
Try It — Semantic Release Config Builder
Related Topics
Prerelease Branch Configuration for semantic-release
Basic Configuration
Basic npm Package Release with semantic-release
Basic Configuration
Automatic Changelog Generation with semantic-release
Basic Configuration
Commit Release Artifacts Back to Repository
Advanced Configuration
Custom Commit Type Release Rules for semantic-release
Advanced Configuration