-
Notifications
You must be signed in to change notification settings - Fork 5
/
release.config.cjs
77 lines (71 loc) · 2.09 KB
/
release.config.cjs
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
const path = require("path");
const { spawnSync } = require("child_process");
// ordered by dependency first, name second
const pkgs = [
{ name: "@postdfm/ast", pkgRoot: "packages/@postdfm/ast" },
{ name: "@postdfm/ast2dfm", pkgRoot: "packages/@postdfm/ast2dfm" },
{ name: "@postdfm/dfm2ast", pkgRoot: "packages/@postdfm/dfm2ast" },
{ name: "@postdfm/plugin", pkgRoot: "packages/@postdfm/plugin" },
{ name: "@postdfm/transform", pkgRoot: "packages/@postdfm/transform" },
{ name: "postdfm", pkgRoot: "packages/postdfm" },
];
const workspaces = spawnSync(
"yarn",
["workspaces", "list", "--json", "--no-private"],
{ shell: true, encoding: "utf-8" },
)
.stdout.split(/[\r\n]+/)
.filter(Boolean)
.map(JSON.parse)
.map(({ name, location }) => ({ name, pkgRoot: location }));
function isPkgEqual(a) {
return (b) => a.name === b.name && a.pkgRoot === b.pkgRoot;
}
if (
!(
workspaces.every((workspace) => pkgs.some(isPkgEqual(workspace))) &&
pkgs.every((pkg) => workspaces.some(isPkgEqual(pkg)))
)
) {
throw new Error(
"Mismatch between public workspaces and packages in release configuration!",
);
}
const tarballDir = path.resolve(__dirname, "dist");
module.exports = {
branches: ["main", { name: "beta", prerelease: true }],
repositoryUrl: "ssh://[email protected]/spiltcoffee/postdfm.git",
plugins: [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
...pkgs.flatMap((pkg) => [
["./release/dependency.cjs", { pkg, pkgs }],
["@semantic-release/npm", { pkgRoot: pkg.pkgRoot, tarballDir }],
]),
"./release/yarnlock.cjs",
[
"@semantic-release/github",
{
assets: pkgs.map(({ name }) => ({
path: path.resolve(
tarballDir,
`${name.replace("@", "").replace("/", "-")}-*.tgz`,
),
label: name,
})),
},
],
[
"@semantic-release/git",
{
assets: [
[
"yarn.lock",
"packages/**/package.json",
"!**/node_modules/**/package.json",
],
],
},
],
],
};