@thisismanta/semantic-version 2.0.0-8 → 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.
@@ -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('Expect to have a valid "version" field in package.json.');
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')
@@ -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 version ${releaseType}`);
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
81
  await run(`git push --follow-tags origin`);
82
82
  console.log(`Pushed Git tags`);
83
- if (semver_1.default.valid(nextVersion) && process.env.GITHUB_TOKEN) {
84
- const commitGroups = {
83
+ if (nextVersion && process.env.GITHUB_TOKEN) {
84
+ const groups = {
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
- commitGroups['BREAKING CHANGES'].push(commit);
92
+ groups['BREAKING CHANGES'].push(commit);
93
93
  }
94
94
  else if (commit.type === 'feat') {
95
- commitGroups['Features'].push(commit);
95
+ groups['Features'].push(commit);
96
96
  }
97
97
  else if (commit.type === 'bug') {
98
- commitGroups['Bug Fixes'].push(commit);
98
+ groups['Bug Fixes'].push(commit);
99
99
  }
100
100
  else {
101
- commitGroups['Others'].push(commit);
101
+ groups['Others'].push(commit);
102
102
  }
103
103
  }
104
- const releaseNote = Object.entries(commitGroups)
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'))
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;
112
111
  // See https://octokit.github.io/rest.js/v19#repos-create-release
113
112
  const releaseRespond = await octokit.rest.repos.createRelease({
114
113
  ...github.context.repo,
115
- tag_name: nextVersion,
114
+ tag_name: 'v' + nextVersion,
116
115
  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');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thisismanta/semantic-version",
3
- "version": "2.0.0-8",
3
+ "version": "2.0.0-9",
4
4
  "author": "Anantachai Saothong <thisismanta@gmail.com>",
5
5
  "license": "ISC",
6
6
  "engines": {