@thisismanta/semantic-version 2.0.0-7 → 2.0.0-9
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/lib/auto-npm-version.js +15 -14
- package/lib/index.js +1 -1
- package/package.json +1 -1
package/lib/auto-npm-version.js
CHANGED
|
@@ -37,7 +37,7 @@ async function main() {
|
|
|
37
37
|
JSON.parse(await run('npm pkg get version')));
|
|
38
38
|
(0, debug_1.debug)('lastVersion »', JSON.stringify(lastVersion));
|
|
39
39
|
if (!lastVersion) {
|
|
40
|
-
throw new Error('
|
|
40
|
+
throw new Error('Could not find last version.');
|
|
41
41
|
}
|
|
42
42
|
const commits = (await run(`git log v${lastVersion}..HEAD --format=%H%s`))
|
|
43
43
|
.split('\n')
|
|
@@ -48,7 +48,7 @@ async function main() {
|
|
|
48
48
|
}))
|
|
49
49
|
.filter(({ message }) => semver_1.default.valid(message) === null)
|
|
50
50
|
.map(({ hash, message }) => {
|
|
51
|
-
const { type, breaking, subject } = (0, index_1.checkConventionalMessage)(message, { debug:
|
|
51
|
+
const { type, breaking, subject } = (0, index_1.checkConventionalMessage)(message, { debug: () => { } });
|
|
52
52
|
return {
|
|
53
53
|
hash,
|
|
54
54
|
type,
|
|
@@ -75,13 +75,13 @@ async function main() {
|
|
|
75
75
|
console.log('Exited without releasing a new version');
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
const nextVersion = await run(`npm version --json --no-commit-hooks ${releaseType}`);
|
|
79
|
-
(0, debug_1.debug)('nextVersion »', nextVersion);
|
|
80
|
-
console.log(`Created
|
|
81
|
-
await run(`git push --follow-tags origin
|
|
78
|
+
const nextVersion = semver_1.default.valid(await run(`npm version --json --no-commit-hooks ${releaseType}`));
|
|
79
|
+
(0, debug_1.debug)('nextVersion »', JSON.stringify(nextVersion));
|
|
80
|
+
console.log(`Created tag ${releaseType}`);
|
|
81
|
+
await run(`git push --follow-tags origin`);
|
|
82
82
|
console.log(`Pushed Git tags`);
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
83
|
+
if (nextVersion && process.env.GITHUB_TOKEN) {
|
|
84
|
+
const groups = {
|
|
85
85
|
'BREAKING CHANGES': [],
|
|
86
86
|
'Features': [],
|
|
87
87
|
'Bug Fixes': [],
|
|
@@ -89,19 +89,19 @@ async function main() {
|
|
|
89
89
|
};
|
|
90
90
|
for (const commit of commits) {
|
|
91
91
|
if (commit.breaking) {
|
|
92
|
-
|
|
92
|
+
groups['BREAKING CHANGES'].push(commit);
|
|
93
93
|
}
|
|
94
94
|
else if (commit.type === 'feat') {
|
|
95
|
-
|
|
95
|
+
groups['Features'].push(commit);
|
|
96
96
|
}
|
|
97
97
|
else if (commit.type === 'bug') {
|
|
98
|
-
|
|
98
|
+
groups['Bug Fixes'].push(commit);
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
|
|
101
|
+
groups['Others'].push(commit);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
const releaseNote = Object.entries(
|
|
104
|
+
const releaseNote = Object.entries(groups)
|
|
105
105
|
.filter(([title, commits]) => commits.length > 0)
|
|
106
106
|
.map(([title, commits]) => `### ${title}\n\n` +
|
|
107
107
|
commits.map(({ subject, hash }) => `- ${subject} (${hash})`).join('\n'))
|
|
@@ -111,8 +111,9 @@ async function main() {
|
|
|
111
111
|
// See https://octokit.github.io/rest.js/v19#repos-create-release
|
|
112
112
|
const releaseRespond = await octokit.rest.repos.createRelease({
|
|
113
113
|
...github.context.repo,
|
|
114
|
-
tag_name: nextVersion,
|
|
114
|
+
tag_name: 'v' + nextVersion,
|
|
115
115
|
body: releaseNote,
|
|
116
|
+
make_latest: true, // TODO: compare with the latest release
|
|
116
117
|
});
|
|
117
118
|
(0, debug_1.debug)('releaseRespond »', JSON.stringify(releaseRespond, null, 2));
|
|
118
119
|
console.log('Created a new release on GitHub');
|
package/lib/index.js
CHANGED
|
@@ -9,7 +9,7 @@ function checkConventionalMessage(message, { debug }) {
|
|
|
9
9
|
debug('type »', type);
|
|
10
10
|
debug('scope »', scope);
|
|
11
11
|
debug('breaking »', breaking);
|
|
12
|
-
debug('subject »', subject);
|
|
12
|
+
debug('subject »', subject?.trim());
|
|
13
13
|
const errors = [
|
|
14
14
|
!type &&
|
|
15
15
|
'The pull request title must match the pattern of "<type>[!]: <subject>" which is a reduced set of https://www.conventionalcommits.org/en/v1.0.0/',
|