-
Notifications
You must be signed in to change notification settings - Fork 2
/
.releaserc.js
94 lines (89 loc) · 2.7 KB
/
.releaserc.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
/** @type {"normal" | "version"} */
const releaseMode = process.env.ARCHIFILTRE_RELEASE_MODE ?? "normal";
const binName = require("./package.json").name;
console.info("Release script ----- Branch", {
originalRef: process.env.GITHUB_REF,
override: process.env.GITHUB_REF_OVERRIDE,
});
/** @type {import("semantic-release").Options["branches"]} */
const branches = [
"main",
{
channel: "next",
name: "dev",
prerelease: "next",
},
{
name: "beta",
prerelease: true,
},
];
const isPreRealse = process.env.GITHUB_REF
? branches.some(
(branch) =>
branch.prerelease &&
`refs/heads/${branch.name}` === process.env.GITHUB_REF
)
: true;
/** @type {import("semantic-release").Options["plugins"]} */
const plugins = [
"@semantic-release/commit-analyzer",
[
"@semantic-release/npm",
{
npmPublish: false,
},
],
];
if (releaseMode === "normal") {
plugins.push("@semantic-release/release-notes-generator");
if (!isPreRealse) {
plugins.push("@semantic-release/changelog", [
"@semantic-release/git",
{
assets: ["CHANGELOG.md", "package.json"],
message:
"chore(${nextRelease.type}-release): ${nextRelease.gitTag} [skip ci]\n\n${nextRelease.notes}",
},
]);
}
plugins.push(
[
"@semantic-release/github",
{
assets: [
`bin/**/${binName}*.@(exe|dmg|AppImage|msi|zip)`,
`bin/**/${binName}*.sha512`,
`bin/**/${binName}*.blockmap`,
`bin/**/latest*.yml`,
],
releasedLabels: false,
successComment: false,
},
],
[
"@semantic-release/exec",
{
publishCmd: `git notes --ref semantic-release add -f -m '{"channels": [\${nextRelease.channel ? JSON.stringify(nextRelease.channel) : null}]}' \${nextRelease.gitTag} && git push --force origin refs/notes/semantic-release`,
},
]
);
} else if (releaseMode === "version") {
plugins.push([
"@semantic-release/exec",
{
publishCmd:
'echo "{\\"deleteLog\\": \\"$(/usr/bin/git tag -d ${nextRelease.gitTag} && /usr/bin/git push origin :${nextRelease.gitTag})\\"}"',
},
]);
} else {
throw new Error(
`process.env.ARCHIFILTRE_RELEASE_MODE unknown (found=${process.env.ARCHIFILTRE_RELEASE_MODE})`
);
}
/** @type {import("semantic-release").Options} */
const config = {
branches,
plugins,
};
module.exports = config;