Skip to content

Commit aface61

Browse files
committed
feat: provide a custom what-bump that accounts for special case where there should be no release
1 parent daf2d34 commit aface61

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

packages/release-it-config/.release-it.cjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
const customWhatBump = require('./bumper');
2+
13
module.exports = {
24
plugins: {
3-
"@release-it/conventional-changelog": {
4-
preset: "angular",
5-
infile: "CHANGELOG.md",
5+
'@release-it/conventional-changelog': {
6+
preset: 'angular',
7+
infile: 'CHANGELOG.md',
68
gitRawCommitsOpts: {
79
path: '.',
810
from: process.env.RELEASE_SCM_BASE,
@@ -11,14 +13,15 @@ module.exports = {
1113
path: '.',
1214
from: process.env.RELEASE_SCM_BASE,
1315
},
16+
whatBump: customWhatBump
1417
}
1518
},
1619
git: {
1720
tag: false, // We want the last version to be derived from the package.json version field.
1821
commitsPath: '.', // Only consider commits in this folder and not the whole repository.
1922
requireCommits: true, // Do not do anything with git if there are no commits.
2023
requireCommitsFail: false, // Do not fail if there are no commits.
21-
commitMessage: "chore(release): released version v${version} [no ci]",
24+
commitMessage: 'chore(release): released version v${version} [no ci]',
2225
},
2326
npm: {
2427
publish: false

packages/release-it-config/bumper.cjs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
module.exports = function whatBump (commits) {
2+
let level = -1 //default to be non-existence level.
3+
let breakings = 0
4+
let features = 0
5+
6+
commits.forEach(commit => {
7+
if (commit.notes.length > 0) {
8+
breakings += commit.notes.length
9+
level = 0
10+
} else if (commit.type === 'feat') {
11+
features += 1
12+
if (level !== 0) { // only change if there is no breaking change already
13+
level = 1
14+
}
15+
}else if(commit.type){ //any other type
16+
level = 2
17+
}
18+
})
19+
20+
return {
21+
level,
22+
reason: breakings === 1
23+
? `There is ${breakings} BREAKING CHANGE and ${features} features`
24+
: `There are ${breakings} BREAKING CHANGES and ${features} features`
25+
}
26+
}

0 commit comments

Comments
 (0)