Repository navigation
Expand file tree
/
Copy pathrelease.config.cjs
More file actions
58 lines (54 loc) · 1.72 KB
/
Copy pathrelease.config.cjs
File metadata and controls
58 lines (54 loc) · 1.72 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
const normalizedSubject = (subject) =>
String(subject || "")
.replace(/\s*\(\[?#\d+\]?(\([^)]*\))?\)\s*$/, "")
.replace(/\s+/g, " ")
.trim()
.toLowerCase();
const commitKey = (commit) => `${(commit.scope || "").toLowerCase()}|${normalizedSubject(commit.subject)}`;
const uniqueBy = (items, key) => {
const seen = new Set();
return items.filter((item) => {
const value = key(item);
if (seen.has(value)) return false;
seen.add(value);
return true;
});
};
const removeDuplicateEntries = (context) => ({
...context,
commitGroups: (context.commitGroups || []).map((group) => ({
...group,
commits: uniqueBy(group.commits || [], commitKey),
})),
noteGroups: (context.noteGroups || []).map((group) => ({
...group,
notes: uniqueBy(group.notes || [], (note) => normalizedSubject(note.text)),
})),
});
module.exports = {
branches: ["main"],
tagFormat: "v${version}",
plugins: [
["@semantic-release/commit-analyzer", { preset: "conventionalcommits" }],
[
"@semantic-release/release-notes-generator",
{ preset: "conventionalcommits", writerOpts: { finalizeContext: removeDuplicateEntries } },
],
["@semantic-release/changelog", { changelogFile: "CHANGELOG.md" }],
[
"@semantic-release/exec",
{
verifyReleaseCmd: "echo ${nextRelease.version} > .next-version",
prepareCmd: "go run ./tools/cmd/ishare-tools set-version ${nextRelease.version}",
},
],
[
"@semantic-release/git",
{
assets: ["Config.xcconfig", "CHANGELOG.md"],
message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
},
],
["@semantic-release/github", { assets: [{ path: "dist/*" }] }],
],
};