-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,289 changed files
with
112,547 additions
and
198,887 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
.github/actions/preprocessing-release-changelog/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: preprocessing-release-changelog | ||
|
||
description: 'Transform release changelog with group by heading' | ||
|
||
inputs: | ||
data: | ||
description: "Raw data for processing" | ||
required: true | ||
|
||
outputs: | ||
changelog: | ||
description: "changelog after processing" | ||
|
||
runs: | ||
using: 'node20' | ||
main: 'index.js' |
40 changes: 40 additions & 0 deletions
40
.github/actions/preprocessing-release-changelog/groupByHeadings.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
export function groupByHeadings(tree) { | ||
const groups = new Map(); | ||
const h2List = new Set(); | ||
|
||
let currentGroup = null; | ||
let currentNodes = []; | ||
|
||
for (const node of tree.children) { | ||
if (node.type === 'heading' && node.depth === 2) { | ||
// Сохраняем предыдущую группу | ||
if (currentGroup) { | ||
const data = [...(groups.get(currentGroup) || []), ...currentNodes]; | ||
|
||
groups.set(currentGroup, data); | ||
} | ||
|
||
const headingValue = node.children[0].value; | ||
|
||
currentGroup = headingValue; | ||
|
||
// Сохраняем заголовок только если он встречается впервые | ||
currentNodes = !h2List.has(headingValue) ? [node] : []; | ||
h2List.add(headingValue); | ||
} else if (currentGroup) { | ||
currentNodes.push(node); | ||
} | ||
} | ||
|
||
// Сохраняем последнюю группу | ||
if (currentGroup && currentNodes.length) { | ||
const data = [...(groups.get(currentGroup) || []), ...currentNodes]; | ||
|
||
groups.set(currentGroup, data); | ||
} | ||
|
||
return { | ||
...tree, | ||
children: [...groups.values()].flat(), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { unified } from 'unified'; | ||
import remarkParse from 'remark-parse'; | ||
import remarkStringify from 'remark-stringify'; | ||
|
||
import * as core from '@actions/core'; | ||
|
||
import { groupByHeadings } from './groupByHeadings.js'; | ||
|
||
async function run() { | ||
try { | ||
const data = core.getInput('data', { required: true }); | ||
|
||
const changelog = await unified() | ||
.use(remarkParse) | ||
.use(() => groupByHeadings) | ||
.use(remarkStringify) | ||
.process(data); | ||
|
||
core.setOutput('changelog', changelog.toLocaleString()); | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} | ||
} | ||
|
||
run(); |
Oops, something went wrong.