@thisismanta/semantic-version 2.0.0-9 → 3.0.0-0
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 +13 -13
- 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('Expect to have a valid "version" field in package.json.');
|
|
41
41
|
}
|
|
42
42
|
const commits = (await run(`git log v${lastVersion}..HEAD --format=%H%s`))
|
|
43
43
|
.split('\n')
|
|
@@ -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 =
|
|
79
|
-
(0, debug_1.debug)('nextVersion »',
|
|
80
|
-
console.log(`Created
|
|
78
|
+
const nextVersion = await run(`npm version --json --no-commit-hooks ${releaseType}`);
|
|
79
|
+
(0, debug_1.debug)('nextVersion »', nextVersion);
|
|
80
|
+
console.log(`Created version ${releaseType}`);
|
|
81
81
|
await run(`git push --follow-tags origin`);
|
|
82
82
|
console.log(`Pushed Git tags`);
|
|
83
|
-
if (nextVersion && process.env.GITHUB_TOKEN) {
|
|
84
|
-
const
|
|
83
|
+
if (semver_1.default.valid(nextVersion) && process.env.GITHUB_TOKEN) {
|
|
84
|
+
const commitGroups = {
|
|
85
85
|
'BREAKING CHANGES': [],
|
|
86
86
|
'Features': [],
|
|
87
87
|
'Bug Fixes': [],
|
|
@@ -89,31 +89,31 @@ async function main() {
|
|
|
89
89
|
};
|
|
90
90
|
for (const commit of commits) {
|
|
91
91
|
if (commit.breaking) {
|
|
92
|
-
|
|
92
|
+
commitGroups['BREAKING CHANGES'].push(commit);
|
|
93
93
|
}
|
|
94
94
|
else if (commit.type === 'feat') {
|
|
95
|
-
|
|
95
|
+
commitGroups['Features'].push(commit);
|
|
96
96
|
}
|
|
97
97
|
else if (commit.type === 'bug') {
|
|
98
|
-
|
|
98
|
+
commitGroups['Bug Fixes'].push(commit);
|
|
99
99
|
}
|
|
100
100
|
else {
|
|
101
|
-
|
|
101
|
+
commitGroups['Others'].push(commit);
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
|
-
const releaseNote = Object.entries(
|
|
104
|
+
const releaseNote = Object.entries(commitGroups)
|
|
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'))
|
|
108
108
|
.join('\n\n');
|
|
109
109
|
(0, debug_1.debug)('releaseNote »', releaseNote);
|
|
110
110
|
const octokit = github.getOctokit(process.env.GITHUB_TOKEN);
|
|
111
|
+
github.context.payload.ref;
|
|
111
112
|
// See https://octokit.github.io/rest.js/v19#repos-create-release
|
|
112
113
|
const releaseRespond = await octokit.rest.repos.createRelease({
|
|
113
114
|
...github.context.repo,
|
|
114
|
-
tag_name:
|
|
115
|
+
tag_name: nextVersion,
|
|
115
116
|
body: releaseNote,
|
|
116
|
-
make_latest: true, // TODO: compare with the latest release
|
|
117
117
|
});
|
|
118
118
|
(0, debug_1.debug)('releaseRespond »', JSON.stringify(releaseRespond, null, 2));
|
|
119
119
|
console.log('Created a new release on GitHub');
|