Repository navigation
Expand file tree
/
Copy pathrelease.config.js
More file actions
127 lines (123 loc) · 3.83 KB
/
Copy pathrelease.config.js
File metadata and controls
127 lines (123 loc) · 3.83 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
module.exports = {
branches: [
"main",
{
name: "beta",
prerelease: true
}
],
plugins: [
[
"@semantic-release/commit-analyzer",
{
preset: "angular",
releaseRules: [
{ type: "chore", breaking: true, release: "major" },
{ type: "chore", scope: "breaking", release: "major" },
],
parserOpts: {
noteKeywords: ["BREAKING CHANGE", "BREAKING CHANGES"],
},
},
],
[
"@semantic-release/release-notes-generator",
{
// Every commit type is listed so a release never gets empty notes
preset: "conventionalcommits",
presetConfig: {
types: [
{ type: "feat", section: "Features" },
{ type: "fix", section: "Bug Fixes" },
{ type: "perf", section: "Performance Improvements" },
{ type: "revert", section: "Reverts" },
{ type: "docs", section: "Documentation" },
{ type: "refactor", section: "Code Refactoring" },
{ type: "build", section: "Build System" },
{ type: "chore", section: "Miscellaneous Chores" },
{ type: "ci", section: "Continuous Integration" },
{ type: "test", section: "Tests" },
{ type: "style", section: "Styles" },
],
},
writerOpts: {
footerPartial: [
"{{#if noteGroups}}",
"{{#each noteGroups}}",
"",
"### {{title}}",
"",
"{{#each notes}}",
"* {{#if commit.scope}}**{{commit.scope}}:** {{/if}}{{text}}",
"{{/each}}",
"{{/each}}",
"",
"{{/if}}",
"{{#if contributors.length}}",
"",
"### Contributors",
"",
"{{#each contributors}}",
"* {{this.displayName}}",
"{{/each}}",
"{{/if}}",
].join("\n"),
finalizeContext: (context, writerOpts, filteredCommits, keyCommit, commits) => {
const contributors = new Map();
const allCommits = commits || filteredCommits || [];
for (const commit of allCommits) {
if (commit.authorName) {
contributors.set(commit.authorName, {
name: commit.authorName,
email: commit.authorEmail || "",
});
}
// Extract co-authors from body and footer trailers
const fullText = [commit.body, commit.footer]
.filter(Boolean)
.join("\n");
const coAuthorRegex =
/Co-Authored-By:\s*(.+?)\s*<(.+?)>/gi;
let match;
while ((match = coAuthorRegex.exec(fullText)) !== null) {
const name = match[1].trim();
contributors.set(name, {
name,
email: match[2].trim(),
});
}
}
context.contributors = Array.from(contributors.values()).map(
(c) => {
// Extract GitHub username from noreply email
const ghMatch = c.email.match(
/^(\d+\+)?(.+)@users\.noreply\.github\.com$/
);
return {
...c,
displayName: `@${ghMatch ? ghMatch[2] : c.name}`,
};
}
);
return context;
},
},
},
],
"@semantic-release/changelog",
[
"@semantic-release/npm",
{
npmPublish: true,
}
],
"@semantic-release/github",
[
"@semantic-release/git",
{
assets: ["package.json", "yarn.lock", "CHANGELOG.md"],
message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
}
]
]
};