forked from databendlabs/databend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_release_note.js
More file actions
41 lines (36 loc) · 1.08 KB
/
Copy pathgenerate_release_note.js
File metadata and controls
41 lines (36 loc) · 1.08 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
const fs = require("fs");
function escapeHtml(text) {
const map = {
"&": "&",
"<": "<",
">": ">",
'"': """,
"'": "'",
};
return text.replace(/[&<>"']/g, (m) => map[m]);
}
module.exports = async ({ github, context, core }) => {
const { VERSION, DATE } = process.env;
fs.mkdirSync("docs/release-stable", { recursive: true });
const df = `docs/release-stable/${DATE}_${VERSION}.md`;
const releases = await github.rest.repos.listReleases({
owner: "databendlabs",
repo: "databend",
});
const release = releases.data.find((r) => r.name === VERSION);
if (!release) {
core.setFailed(`Release ${VERSION} not found`);
return;
}
let body = release.body;
body = body.split("\n").slice(1).join("\n");
body = "---\n" + body;
body = body.replace(/^--$/gm, "---");
body = body.replace(/^asset:.*$/gm, "");
body = body.replace(
/https:\/\/github\.com\/databendlabs\/databend\/pull\/([0-9]+)/g,
"[#$1](https://github.com/databendlabs/databend/pull/$1)"
);
body = escapeHtml(body);
fs.writeFileSync(df, body);
};