-
Notifications
You must be signed in to change notification settings - Fork 0
/
.releaserc.js
115 lines (110 loc) · 3.03 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// in ".releaserc.js" or "release.config.js"
const dateFormat = require("dateformat");
const fs = require("fs");
const path = require("path");
const gitmojis = require("gitmojis").gitmojis;
const TEMPLATE_DIR = "./.semantic-release/templates/";
const template = fs.readFileSync(
path.join(TEMPLATE_DIR, "default-template.hbs")
);
const commitTemplate = fs.readFileSync(
path.join(TEMPLATE_DIR, "commit-template.hbs")
);
const MAJOR = "major";
const MINOR = "minor";
const PATCH = "patch";
const RULES = {
major: gitmojis
.filter(({ semver }) => semver === MAJOR)
.map(({ emoji }) => emoji),
minor: gitmojis
.filter(({ semver }) => semver === MINOR)
.map(({ emoji }) => emoji),
patch: gitmojis
.filter(({ semver }) => semver === PATCH)
.map(({ emoji }) => emoji),
others: gitmojis
.filter(({ semver }) => semver === null)
.map(({ emoji }) => emoji)
.filter((emoji) => emoji != "👷"),
};
module.exports = {
branches: [
"main",
"next",
{
name: "beta",
prerelease: true,
},
{
name: "alpha",
prerelease: true,
},
],
plugins: [
[
"semantic-release-gitmoji",
{
releaseRules: RULES,
releaseNotes: {
template,
partials: { commitTemplate },
helpers: {
datetime: function (format = "UTC:yyyy-mm-dd") {
return dateFormat(new Date(), format);
},
commitlist: function (commits, options) {
let commitlist = {};
let currRule = null;
const rules = RULES;
for (const iGitmoji in commits) {
currRule = null;
for (const iRule in rules) {
if (rules[iRule].includes(iGitmoji)) {
if (
!Object.prototype.hasOwnProperty.call(commitlist, iRule)
) {
commitlist[iRule] = [];
}
currRule = iRule;
break;
}
}
if (currRule != null) {
for (
let idxCommit = 0;
idxCommit < commits[iGitmoji].length;
idxCommit++
) {
commitlist[currRule].push(commits[iGitmoji][idxCommit]);
}
}
options.data.root["commits"] = commitlist;
}
},
},
issueResolution: {
template: "{baseUrl}/{owner}/{repo}/issues/{ref}",
baseUrl: "https://github.com",
},
},
},
],
[
"@semantic-release/changelog",
{
changelogFile: "CHANGELOG.md",
changelogTitle: "# CHANGELOG",
},
],
// [
// "@semantic-release/git",
// {
// assets: ["CHANGELOG.md", "package.json"],
// message:
// "🔖 Release ${nextRelease.version} [NO-CI]\n\n${nextRelease.notes}",
// },
// ],
],
tagFormat: "${version}",
};