-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathrelease.mjs
45 lines (39 loc) · 1.28 KB
/
release.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import release from 'release-it';
const branch = process.env.BRANCH || process.env.CI_REF_NAME || '';
const branchSlug = branch.replace(/\//g, '-');
const branchPrefix = branch.split('/')[0];
/**
* @type {import('release-it').Config}
*/
const config = {
isPreRelease: branch !== 'master',
preRelease: branch !== 'master',
preReleaseId: branch === 'master' ? '' : branch,
plugins: {
'@release-it/conventional-changelog': {
preset: {
name: 'conventionalcommits',
types: [
{ type: 'breaking', release: 'major' },
{ type: 'feat', release: 'minor' },
// match anything else
{ type: '**', release: 'patch' },
{ subject: '**', release: 'patch' },
{ message: '**', release: 'patch' },
],
},
},
},
};
release(config).then((output) => {
console.debug('output', output);
const { version: nextVersion, latestVersion, name, changelog } = output || {};
console.info(`Last release is ${latestVersion} and next release is ${nextVersion}`);
if (latestVersion === nextVersion) {
console.info(`No release is needed, last release is ${latestVersion} and next release is ${nextVersion}`);
return;
}
if (!nextVersion) {
console.info(`No release is needed - no next version`);
}
});