-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
100 lines (98 loc) · 2.39 KB
/
index.js
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
const releaseRules = [
{
type: 'build',
release: 'patch',
},
{
type: 'ci',
release: 'patch',
},
{
type: 'chore',
release: 'patch',
},
{
type: 'docs',
release: 'patch',
},
{
type: 'refactor',
release: 'patch',
},
{
type: 'style',
release: 'patch',
},
{
type: 'test',
release: 'patch',
},
]
function getSuccessComment() {
// note: spaces will break the generated markdown
return (
'' +
":tada: This <%= issue.pull_request ? 'PR is included' : 'issue has been resolved' %> in version <%= nextRelease.version %> :tada:" +
'<% if(typeof releases !== "undefined" && Array.isArray(releases) && releases.length > 0) { %>' +
'<% var releaseInfos = releases.filter(function(release) { return !!release.name }) %>' +
'<% if(releaseInfos.length) { %>' +
'\n\nThe release is available on' +
'<% if (releaseInfos.length === 1) { %>' +
' ' +
'<% if(releaseInfos[0].url) { %>' +
'[<%= releaseInfos[0].name %>](<%= releaseInfos[0].url %>)' +
'<% } else { %>' +
'<%= releaseInfos[0].name %>' +
'<% } %>' +
'<% } else { %>' +
':' +
'<% releaseInfos.forEach(function(release) { %>' +
'\n- ' +
'<% if(release.url) { %>' +
'[<%= release.name %>](<%= release.url %>)' +
'<% } else { %>' +
'<%= release.name %>' +
'<% } %>' +
'<% }) %>' +
'<% } %>' +
'<% } %>' +
'<% } %>'
)
}
module.exports = {
plugins: [
[
'@semantic-release/commit-analyzer',
{
releaseRules,
},
],
'@semantic-release/release-notes-generator',
'@semantic-release/changelog',
[
"@semantic-release/exec", {
prepareCmd: [
'majorVersion=$(echo "${nextRelease.version}" | cut -d"." -f 1)',
'minorVersion=$(echo "${nextRelease.version}" | cut -d"." -f 2)',
'git push origin :refs/tags/v$majorVersion',
'git tag -f v$majorVersion ${nextRelease.gitHead}',
'git push origin :refs/tags/v$majorVersion.$minorVersion',
'git tag -f v$majorVersion.$minorVersion ${nextRelease.gitHead}',
].join(' && ')
},
],
[
'@semantic-release/github',
{
successComment: getSuccessComment(),
addReleases: 'bottom',
},
],
[
'@semantic-release/git',
{
assets: ['dist/**', 'package.json', 'CHANGELOG.md'],
},
],
],
}