commit-and-tag-version 12.6.1 → 12.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yaml +1 -1
- package/.github/workflows/release-please.yml +7 -3
- package/CHANGELOG.md +19 -0
- package/command.js +6 -0
- package/index.js +1 -0
- package/lib/lifecycles/bump.js +51 -0
- package/lib/updaters/types/gradle.js +1 -1
- package/package.json +3 -3
- package/test/core.spec.js +94 -0
- package/test/mocks/build-6.4.0-snapshot.gradle.kts +14 -0
- package/test/mocks/jest-mocks.js +18 -0
|
@@ -23,7 +23,7 @@ jobs:
|
|
|
23
23
|
OS: ${{ matrix.os }}
|
|
24
24
|
NODE_VERSION: ${{ matrix.node }}
|
|
25
25
|
steps:
|
|
26
|
-
- uses: actions/checkout@
|
|
26
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
|
|
27
27
|
- run: git fetch --prune --unshallow
|
|
28
28
|
- run: git config --global user.name 'Actions'
|
|
29
29
|
- run: git config --global user.email 'dummy@example.org'
|
|
@@ -4,6 +4,12 @@ on:
|
|
|
4
4
|
branches:
|
|
5
5
|
- master
|
|
6
6
|
name: release-please
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
id-token: write # Required for OIDC
|
|
10
|
+
contents: write
|
|
11
|
+
issues: write
|
|
12
|
+
pull-requests: write
|
|
7
13
|
jobs:
|
|
8
14
|
release-please:
|
|
9
15
|
runs-on: ubuntu-latest
|
|
@@ -15,7 +21,7 @@ jobs:
|
|
|
15
21
|
release-type: node
|
|
16
22
|
package-name: commit-and-tag-version
|
|
17
23
|
# The logic below handles the npm publication:
|
|
18
|
-
- uses: actions/checkout@
|
|
24
|
+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v4
|
|
19
25
|
# these if statements ensure that a publication only occurs when
|
|
20
26
|
# a new release is created:
|
|
21
27
|
if: ${{ steps.release.outputs.release_created }}
|
|
@@ -27,6 +33,4 @@ jobs:
|
|
|
27
33
|
- run: npm ci
|
|
28
34
|
if: ${{ steps.release.outputs.release_created }}
|
|
29
35
|
- run: npm publish
|
|
30
|
-
env:
|
|
31
|
-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
|
|
32
36
|
if: ${{ steps.release.outputs.release_created }}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [12.7.1](https://github.com/absolute-version/commit-and-tag-version/compare/v12.7.0...v12.7.1) (2026-03-18)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* 🐛 updating dependency fast-xml-parser ([#277](https://github.com/absolute-version/commit-and-tag-version/issues/277)) ([dac372b](https://github.com/absolute-version/commit-and-tag-version/commit/dac372bfa8b8b124a1e9a8760074a86a641476f9))
|
|
11
|
+
|
|
12
|
+
## [12.7.0](https://github.com/absolute-version/commit-and-tag-version/compare/v12.6.1...v12.7.0) (2026-03-17)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Features
|
|
16
|
+
|
|
17
|
+
* add --noBumpWhenEmptyChanges flag ([#274](https://github.com/absolute-version/commit-and-tag-version/issues/274)) ([b60fb23](https://github.com/absolute-version/commit-and-tag-version/commit/b60fb237b78622a5d523423d1b40e87aeb8631b5))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* make prerelease-flag work with gradle files ([#273](https://github.com/absolute-version/commit-and-tag-version/issues/273)) ([24e2f02](https://github.com/absolute-version/commit-and-tag-version/commit/24e2f028ac5634f278bcd2980d87faabd70647e4))
|
|
23
|
+
|
|
5
24
|
## [12.6.1](https://github.com/absolute-version/commit-and-tag-version/compare/v12.6.0...v12.6.1) (2025-12-01)
|
|
6
25
|
|
|
7
26
|
|
package/command.js
CHANGED
|
@@ -138,6 +138,12 @@ const yargs = require('yargs')
|
|
|
138
138
|
alias: 'c',
|
|
139
139
|
describe: 'Path to a custom configuration file',
|
|
140
140
|
})
|
|
141
|
+
.option('noBumpWhenEmptyChanges', {
|
|
142
|
+
type: 'boolean',
|
|
143
|
+
default: false,
|
|
144
|
+
describe:
|
|
145
|
+
'Avoid bumping files and generating changelog if there are no changes.',
|
|
146
|
+
})
|
|
141
147
|
.check((argv) => {
|
|
142
148
|
if (typeof argv.scripts !== 'object' || Array.isArray(argv.scripts)) {
|
|
143
149
|
throw Error('scripts must be an object');
|
package/index.js
CHANGED
|
@@ -85,6 +85,7 @@ module.exports = async function standardVersion(argv) {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
const newVersion = await bump(args, version);
|
|
88
|
+
if (!newVersion) return;
|
|
88
89
|
await changelog(args, newVersion);
|
|
89
90
|
await commit(args, newVersion);
|
|
90
91
|
await tag(newVersion, pkg ? pkg.private : false, args);
|
package/lib/lifecycles/bump.js
CHANGED
|
@@ -13,9 +13,47 @@ const semver = require('semver');
|
|
|
13
13
|
const writeFile = require('../write-file');
|
|
14
14
|
const { resolveUpdaterObjectFromArgument } = require('../updaters');
|
|
15
15
|
const gitSemverTags = require('git-semver-tags');
|
|
16
|
+
const addBangNotes = require('conventional-changelog-conventionalcommits/add-bang-notes');
|
|
16
17
|
let configsToUpdate = {};
|
|
17
18
|
const sanitizeQuotesRegex = /['"]+/g;
|
|
18
19
|
|
|
20
|
+
function noBumpWhenEmptyChanges(config, commits) {
|
|
21
|
+
let level = 2;
|
|
22
|
+
let breakings = 0;
|
|
23
|
+
let features = 0;
|
|
24
|
+
let fix = 0;
|
|
25
|
+
|
|
26
|
+
commits.forEach((commit) => {
|
|
27
|
+
addBangNotes(commit);
|
|
28
|
+
if (commit.notes.length > 0) {
|
|
29
|
+
breakings += commit.notes.length;
|
|
30
|
+
level = 0;
|
|
31
|
+
} else if (commit.type === 'feat' || commit.type === 'feature') {
|
|
32
|
+
features += 1;
|
|
33
|
+
if (level === 2) {
|
|
34
|
+
level = 1;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (commit.type === 'fix') {
|
|
38
|
+
fix += 1;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
if (config.preMajor && level < 2) {
|
|
43
|
+
level++;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!breakings && !features && !fix) return {};
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
level,
|
|
50
|
+
reason:
|
|
51
|
+
breakings === 1
|
|
52
|
+
? `There is ${breakings} BREAKING CHANGE and ${features} features`
|
|
53
|
+
: `There are ${breakings} BREAKING CHANGES and ${features} features`,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
19
57
|
async function Bump(args, version) {
|
|
20
58
|
// reset the cache of updated config files each
|
|
21
59
|
// time we perform the version bump step.
|
|
@@ -42,6 +80,7 @@ async function Bump(args, version) {
|
|
|
42
80
|
const prebumpString = stdout.trim().replace(sanitizeQuotesRegex, '');
|
|
43
81
|
if (semver.valid(prebumpString)) args.releaseAs = prebumpString;
|
|
44
82
|
}
|
|
83
|
+
|
|
45
84
|
if (!args.firstRelease) {
|
|
46
85
|
if (semver.valid(args.releaseAs)) {
|
|
47
86
|
const releaseAs = new semver.SemVer(args.releaseAs);
|
|
@@ -76,6 +115,11 @@ async function Bump(args, version) {
|
|
|
76
115
|
newVersion = semvarToVersionStr(newVersion, releaseAs.build);
|
|
77
116
|
} else {
|
|
78
117
|
const release = await bumpVersion(args.releaseAs, version, args);
|
|
118
|
+
|
|
119
|
+
if (!Object.keys(release).length) {
|
|
120
|
+
checkpoint(args, 'no commits found, so not bumping version', []);
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
79
123
|
const releaseType = getReleaseType(
|
|
80
124
|
args.prerelease,
|
|
81
125
|
release.releaseType,
|
|
@@ -212,6 +256,13 @@ function bumpVersion(releaseAs, currentVersion, args) {
|
|
|
212
256
|
),
|
|
213
257
|
}
|
|
214
258
|
: {}),
|
|
259
|
+
...(args.noBumpWhenEmptyChanges
|
|
260
|
+
? {
|
|
261
|
+
whatBump(commits) {
|
|
262
|
+
return noBumpWhenEmptyChanges(presetOptions, commits);
|
|
263
|
+
},
|
|
264
|
+
}
|
|
265
|
+
: {}),
|
|
215
266
|
},
|
|
216
267
|
args.parserOpts,
|
|
217
268
|
function (err, release) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commit-and-tag-version",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.7.1",
|
|
4
4
|
"description": "replacement for `npm version` with automatic CHANGELOG generation",
|
|
5
5
|
"bin": "bin/cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"detect-indent": "^6.1.0",
|
|
48
48
|
"detect-newline": "^3.1.0",
|
|
49
49
|
"dotgitignore": "^2.1.0",
|
|
50
|
-
"fast-xml-parser": "^5.
|
|
50
|
+
"fast-xml-parser": "^5.5.6",
|
|
51
51
|
"figures": "^3.2.0",
|
|
52
52
|
"find-up": "^5.0.0",
|
|
53
53
|
"git-semver-tags": "^5.0.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"eslint-plugin-import": "^2.31.0",
|
|
63
63
|
"eslint-plugin-jest": "^28.8.3",
|
|
64
64
|
"eslint-plugin-n": "^17.21.3",
|
|
65
|
-
"eslint-plugin-promise": "^7.1
|
|
65
|
+
"eslint-plugin-promise": "^7.2.1",
|
|
66
66
|
"jest": "^29.7.0",
|
|
67
67
|
"jest-serial-runner": "^1.2.1",
|
|
68
68
|
"prettier": "^3.3.3",
|
package/test/core.spec.js
CHANGED
|
@@ -158,6 +158,7 @@ function mock({
|
|
|
158
158
|
bump,
|
|
159
159
|
changelog,
|
|
160
160
|
tags,
|
|
161
|
+
commits,
|
|
161
162
|
existingChangelog,
|
|
162
163
|
testFiles,
|
|
163
164
|
realTestFiles,
|
|
@@ -174,6 +175,10 @@ function mock({
|
|
|
174
175
|
tags,
|
|
175
176
|
});
|
|
176
177
|
|
|
178
|
+
mockers.mockGitRawCommits({
|
|
179
|
+
commits,
|
|
180
|
+
});
|
|
181
|
+
|
|
177
182
|
// needs to be set after mockery, but before mock-fs
|
|
178
183
|
standardVersion = require('../index');
|
|
179
184
|
|
|
@@ -913,6 +918,58 @@ describe('cli', function () {
|
|
|
913
918
|
expect(consoleErrorSpy).not.toHaveBeenCalled();
|
|
914
919
|
expect(consoleInfoSpy).not.toHaveBeenCalled();
|
|
915
920
|
});
|
|
921
|
+
|
|
922
|
+
it('bumps using actual recommendedBump when there are no semver relevant changes and --noBumpWhenEmptyChanges flag is not set', async function () {
|
|
923
|
+
mock({
|
|
924
|
+
bump: jest.requireActual('conventional-recommended-bump'),
|
|
925
|
+
changelog: ['chore release\n'],
|
|
926
|
+
tags: ['v1.0.0'],
|
|
927
|
+
commits: ['chore: update deps\n\n-hash-\nabc123\n'],
|
|
928
|
+
});
|
|
929
|
+
|
|
930
|
+
await exec();
|
|
931
|
+
|
|
932
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.0.1' });
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
it('bumps using actual recommendedBump when there are semver relevant changes and --noBumpWhenEmptyChanges flag is not set', async function () {
|
|
936
|
+
mock({
|
|
937
|
+
bump: jest.requireActual('conventional-recommended-bump'),
|
|
938
|
+
changelog: ['feat release\n'],
|
|
939
|
+
tags: ['v1.0.0'],
|
|
940
|
+
commits: ['feat: shiny new stuff\n\n-hash-\nabc123\n'],
|
|
941
|
+
});
|
|
942
|
+
|
|
943
|
+
await exec();
|
|
944
|
+
|
|
945
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
it('does not bump when there are no semver relevant changes and --noBumpWhenEmptyChanges flag is set', async function () {
|
|
949
|
+
mock({
|
|
950
|
+
bump: jest.requireActual('conventional-recommended-bump'),
|
|
951
|
+
changelog: ['chore release\n'],
|
|
952
|
+
tags: ['v1.0.0'],
|
|
953
|
+
commits: ['chore: update deps\n\n-hash-\nabc123\n'],
|
|
954
|
+
});
|
|
955
|
+
|
|
956
|
+
await exec('--noBumpWhenEmptyChanges');
|
|
957
|
+
|
|
958
|
+
expect(writeFileSyncSpy).not.toHaveBeenCalled();
|
|
959
|
+
});
|
|
960
|
+
|
|
961
|
+
it('bumps when there are semver relevant changes and --noBumpWhenEmptyChanges flag is set', async function () {
|
|
962
|
+
mock({
|
|
963
|
+
bump: jest.requireActual('conventional-recommended-bump'),
|
|
964
|
+
changelog: ['feat release\n'],
|
|
965
|
+
tags: ['v1.0.0'],
|
|
966
|
+
commits: ['feat: shiny new stuff\n\n-hash-\nabc123\n'],
|
|
967
|
+
});
|
|
968
|
+
|
|
969
|
+
await exec('--noBumpWhenEmptyChanges');
|
|
970
|
+
|
|
971
|
+
verifyPackageVersion({ writeFileSyncSpy, expectedVersion: '1.1.0' });
|
|
972
|
+
});
|
|
916
973
|
});
|
|
917
974
|
|
|
918
975
|
describe('commit-and-tag-version', function () {
|
|
@@ -1388,6 +1445,43 @@ describe('cli', function () {
|
|
|
1388
1445
|
expect(calledWithContentStr).toEqual(expected);
|
|
1389
1446
|
});
|
|
1390
1447
|
|
|
1448
|
+
it('bumps to prerelease version in Gradle `build.gradle.kts` file', async function () {
|
|
1449
|
+
const expected = fs.readFileSync(
|
|
1450
|
+
'./test/mocks/build-6.4.0-snapshot.gradle.kts',
|
|
1451
|
+
'utf-8',
|
|
1452
|
+
);
|
|
1453
|
+
|
|
1454
|
+
const filename = 'build.gradle.kts';
|
|
1455
|
+
mock({
|
|
1456
|
+
bump: 'minor',
|
|
1457
|
+
realTestFiles: [
|
|
1458
|
+
{
|
|
1459
|
+
filename,
|
|
1460
|
+
path: './test/mocks/build-6.3.1.gradle.kts',
|
|
1461
|
+
},
|
|
1462
|
+
],
|
|
1463
|
+
});
|
|
1464
|
+
|
|
1465
|
+
await exec({
|
|
1466
|
+
prerelease: 'SNAPSHOT',
|
|
1467
|
+
packageFiles: [{ filename, type: 'gradle' }],
|
|
1468
|
+
bumpFiles: [{ filename, type: 'gradle' }],
|
|
1469
|
+
});
|
|
1470
|
+
|
|
1471
|
+
// filePath is the first arg passed to writeFileSync
|
|
1472
|
+
const packageJsonWriteFileSynchCall = findWriteFileCallForPath({
|
|
1473
|
+
writeFileSyncSpy,
|
|
1474
|
+
filename,
|
|
1475
|
+
});
|
|
1476
|
+
|
|
1477
|
+
if (!packageJsonWriteFileSynchCall) {
|
|
1478
|
+
throw new Error(`writeFileSynch not invoked with path ${filename}`);
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1481
|
+
const calledWithContentStr = packageJsonWriteFileSynchCall[1];
|
|
1482
|
+
expect(calledWithContentStr).toEqual(expected);
|
|
1483
|
+
});
|
|
1484
|
+
|
|
1391
1485
|
it('bumps version in .NET `Project.csproj` file', async function () {
|
|
1392
1486
|
const expected = fs.readFileSync(
|
|
1393
1487
|
'./test/mocks/Project-6.4.0.csproj',
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
plugins {
|
|
2
|
+
id("org.springframework.boot") version "2.4.6"
|
|
3
|
+
kotlin("jvm") version "1.4.31"
|
|
4
|
+
kotlin("plugin.spring") version "1.4.31"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
version = "6.4.0-SNAPSHOT.0"
|
|
8
|
+
java.sourceCompatibility = JavaVersion.VERSION_1_8
|
|
9
|
+
|
|
10
|
+
repositories {
|
|
11
|
+
mavenLocal()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
|
package/test/mocks/jest-mocks.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
const gitSemverTags = require('git-semver-tags');
|
|
2
2
|
const conventionalChangelog = require('conventional-changelog');
|
|
3
3
|
const conventionalRecommendedBump = require('conventional-recommended-bump');
|
|
4
|
+
const gitRawCommits = require('git-raw-commits');
|
|
4
5
|
|
|
5
6
|
const { Readable } = require('stream');
|
|
6
7
|
|
|
7
8
|
jest.mock('conventional-changelog');
|
|
8
9
|
jest.mock('conventional-recommended-bump');
|
|
9
10
|
jest.mock('git-semver-tags');
|
|
11
|
+
jest.mock('git-raw-commits');
|
|
10
12
|
|
|
11
13
|
const mockGitSemverTags = ({ tags = [] }) => {
|
|
12
14
|
gitSemverTags.mockImplementation((opts, cb) => {
|
|
@@ -15,6 +17,21 @@ const mockGitSemverTags = ({ tags = [] }) => {
|
|
|
15
17
|
});
|
|
16
18
|
};
|
|
17
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @param { { commits: string[] } }
|
|
22
|
+
* a commit should look like `<rawBody>\n\n-hash-\n<hash>\n`
|
|
23
|
+
*/
|
|
24
|
+
const mockGitRawCommits = ({ commits = [] }) => {
|
|
25
|
+
gitRawCommits.mockImplementation(() => {
|
|
26
|
+
return new Readable({
|
|
27
|
+
read() {
|
|
28
|
+
commits.forEach((c) => this.push(c));
|
|
29
|
+
this.push(null);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
18
35
|
const mockConventionalChangelog = ({ changelog }) => {
|
|
19
36
|
conventionalChangelog.mockImplementation(
|
|
20
37
|
(opt) =>
|
|
@@ -43,6 +60,7 @@ const mockRecommendedBump = ({ bump }) => {
|
|
|
43
60
|
|
|
44
61
|
module.exports = {
|
|
45
62
|
mockGitSemverTags,
|
|
63
|
+
mockGitRawCommits,
|
|
46
64
|
mockConventionalChangelog,
|
|
47
65
|
mockRecommendedBump,
|
|
48
66
|
};
|