Changelog generation
This commit is contained in:
rodič
7895d15d10
revize
df125e47fa
|
@ -21,6 +21,9 @@ jobs:
|
|||
- name: Build sources
|
||||
run: make
|
||||
|
||||
- name: Build changelog
|
||||
run: make changelog
|
||||
|
||||
- name: Add custom domain
|
||||
run: "touch dist/CNAME && echo \"spec.utxo.cz\" >> dist/CNAME"
|
||||
|
||||
|
|
3
Makefile
3
Makefile
|
@ -66,3 +66,6 @@ server:
|
|||
|
||||
media-kit:
|
||||
deno run --unstable --allow-read --allow-run utils/media-kit.js
|
||||
|
||||
changelog:
|
||||
deno run --unstable --allow-read --allow-write --allow-run utils/changelog.js
|
||||
|
|
|
@ -44,7 +44,6 @@ Všechny datové sady v jednom souboru:
|
|||
|
||||
- [https://spec.utxo.cz/22/bundle.json](https://spec.utxo.cz/22/bundle.json)
|
||||
|
||||
|
||||
## Datové sady
|
||||
|
||||
| | Popis | Ročník 2022 |
|
||||
|
@ -78,4 +77,3 @@ https://json-schema.app/view/%23%2Fdefinitions%2Fspeaker?url=https%3A%2F%2Fspec.
|
|||
- Web: [utxo.cz](https://utxo.cz)
|
||||
- Dokumentace: [docs.utxo.cz](https://docs.utxo.cz)
|
||||
- Foundation: [utxo.foundation](https://utxo.foundation)
|
||||
|
||||
|
|
|
@ -707,6 +707,8 @@
|
|||
|
||||
- id: pavel-kahoun
|
||||
name: Pavel Kahoun
|
||||
nickname: Paulkadotter
|
||||
twitter: paulkadotter
|
||||
orgs:
|
||||
Člen [Polkadotters](https://twitter.com/polkadotterss)
|
||||
country: cz
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
import { load } from "https://deno.land/x/js_yaml_port@3.14.0/js-yaml.js";
|
||||
import { format } from "https://deno.land/std/datetime/mod.ts";
|
||||
|
||||
async function runCommand(cmd) {
|
||||
//console.log(cmd.join(' '))
|
||||
const p = await Deno.run({ cmd, stdout: "piped", stderr: "piped" });
|
||||
/*const pStatus = await p.status();
|
||||
if (pStatus.code !== 0) {
|
||||
const err = new TextDecoder().decode(await p.stderrOutput())
|
||||
throw err;
|
||||
}*/
|
||||
return new TextDecoder().decode(await p.output());
|
||||
}
|
||||
|
||||
async function gitCommits() {
|
||||
const resp = await runCommand([
|
||||
"git",
|
||||
"--no-pager",
|
||||
"log",
|
||||
'--format=format:"%H;%cs"',
|
||||
"1ba66399e6989c038dc7d362d7bd2c7653a65512..gh-pages",
|
||||
]);
|
||||
return resp.split("\n").map((i) => {
|
||||
const [hash, date] = i.replace(new RegExp('^"(.+)"$'), "$1").split(";");
|
||||
return { hash, date };
|
||||
}).reverse();
|
||||
}
|
||||
|
||||
async function gitCommitFile(commit, file) {
|
||||
let out;
|
||||
try {
|
||||
out = await runCommand([
|
||||
"git",
|
||||
"--no-pager",
|
||||
"show",
|
||||
`${commit.hash}:${file}`,
|
||||
]);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function checkCol(col, d, current) {
|
||||
for (const sp of d.json.spec[col]) {
|
||||
if (!current.spec[col].find((s) => s.id === sp.id)) {
|
||||
if (!d[col].added) {
|
||||
d[col].added = [];
|
||||
}
|
||||
d[col].added.push([sp.id, sp.name]);
|
||||
}
|
||||
}
|
||||
for (const sp of current.spec[col]) {
|
||||
if (!d.json.spec[col].find((s) => s.id === sp.id)) {
|
||||
if (!d[col].removed) {
|
||||
d[col].removed = [];
|
||||
}
|
||||
d[col].removed.push([sp.id, sp.name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const files = ["spec/22/speakers.yaml"];
|
||||
const commits = await gitCommits();
|
||||
const dates = {};
|
||||
const cols = {
|
||||
speakers: { title: "Přednášející", url: "lide" },
|
||||
events: { title: "Události", url: "udalosti" },
|
||||
};
|
||||
const types = {
|
||||
added: { title: "přidáno" },
|
||||
removed: { title: "odebráno" },
|
||||
};
|
||||
|
||||
for (const commit of commits) {
|
||||
if (!dates[commit.date]) {
|
||||
dates[commit.date] = { json: null, speakers: {}, events: {} };
|
||||
}
|
||||
const file = await gitCommitFile(commit, "22/bundle.json");
|
||||
if (!file) {
|
||||
continue;
|
||||
}
|
||||
dates[commit.date].json = JSON.parse(file);
|
||||
}
|
||||
|
||||
let current = null;
|
||||
const output = [];
|
||||
for (const date of Object.keys(dates)) {
|
||||
const d = dates[date];
|
||||
if (current) {
|
||||
for (const col of Object.keys(cols)) {
|
||||
checkCol(col, d, current);
|
||||
}
|
||||
}
|
||||
current = d.json;
|
||||
output.push({ date, speakers: d.speakers, events: d.events });
|
||||
}
|
||||
|
||||
const items = [];
|
||||
for (const d of output.reverse()) {
|
||||
const sitems = [];
|
||||
for (const col of Object.keys(cols)) {
|
||||
for (const type of Object.keys(types)) {
|
||||
if (d[col][type]) {
|
||||
for (const i of d[col][type]) {
|
||||
sitems.push(
|
||||
`* [${cols[col].title}] ${types[type].title} [${
|
||||
i[1]
|
||||
}](https://utxo.cz/${cols[col].url}?id=${i[0]})`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sitems.length > 0) {
|
||||
items.push(
|
||||
`## ${format(new Date(d.date), "d.M.yyyy")}\n\n` + sitems.join("\n") +
|
||||
"\n",
|
||||
);
|
||||
}
|
||||
}
|
||||
const str = `# Changelog\n\n${items.join("\n")}`;
|
||||
const fn = "./dist/CHANGELOG.md";
|
||||
await Deno.writeTextFile(fn, str);
|
||||
console.log(`Changelog write to file: ${fn}`);
|
||||
}
|
||||
|
||||
run();
|
Načítá se…
Odkázat v novém úkolu