-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.config.js
More file actions
97 lines (84 loc) · 2.27 KB
/
release.config.js
File metadata and controls
97 lines (84 loc) · 2.27 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
const { execSync } = require("child_process");
const MAIN_BRANCH = "main";
const branchName = execSync("git rev-parse --abbrev-ref HEAD")
.toString()
.replace("\n", "");
const getPrereleaseId = () => {
const currentShaChars = execSync("git rev-parse HEAD").toString();
const currentSha = currentShaChars.substr(0, 6);
const tagsOutput = execSync("git ls-remote --tags").toString().split("\n");
const tags = tagsOutput
.map((tagString) => {
const execResult = /\/tags\/(?<tag>.*)$/.exec(tagString);
if (!execResult) return null;
return execResult.groups.tag;
})
.filter((tag) => tag && tag.includes(branchName))
.map((tag) => tag.substr(tag.indexOf(branchName)));
let shaVersion = 0;
let prereleaseName = `${branchName}-${currentSha}`;
while (tags.includes(`${prereleaseName}.1`)) {
shaVersion += 1;
prereleaseName = `${prereleaseName}-${shaVersion}`;
}
prereleaseName = prereleaseName.replace(`${branchName}-`, "");
const prereleaseId = `\${name}-${prereleaseName}`;
return prereleaseId;
};
const preId = getPrereleaseId();
const basePlugins = [
[
"@semantic-release/commit-analyzer",
{
releaseRules: [
{ tag: "Upgrade", release: "patch" },
{ tag: "Refactor", release: "patch" },
{ tag: "Patch", release: "patch" },
],
},
],
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
];
const mainConfig = {
plugins: [
...basePlugins,
[
"@semantic-release/github",
{
assets: "*.tgz",
},
],
[
"@semantic-release/git",
{
message:
"Docs: ${nextRelease.version} [skip ci]\n\n${nextRelease.note}",
},
],
],
};
const branchConfig = {
plugins: [
...basePlugins,
[
"@semantic-release/exec",
{
successCmd:
'echo "NEXT_VERSION=${nextRelease.version}" >> $GITHUB_OUTPUT',
},
],
],
};
const config = branchName === MAIN_BRANCH ? mainConfig : branchConfig;
module.exports = {
branches: [
MAIN_BRANCH,
{ name: branchName, channel: "${name}", prerelease: preId },
],
preset: "eslint",
repositoryUrl: "git@github.com:WTW-IM/scriptloader-component.git",
...config,
};