feat: Include new contributors in the changelog (#49)

* feat: Add mention-new-contributors input

* deps: Add marked version 4.0.14

* feat: Include new contributors in the changelog

* revert: Test workflow changes
This commit is contained in:
Ardalan Amini authored and GitHub committed 2022-04-29 11:18:38 +04:30
1 parent 49a93eccf5
commit a3982c4b9b
11 files changed
+130 -4

No files matched your search

+21
View File
@@ -1,5 +1,6 @@
import { info, setFailed, setOutput } from "@actions/core";
import { context, getOctokit } from "@actions/github";
import { marked } from "marked";
import SemVer from "semver";
import { getTagSha } from "./tag.js";
import { generate } from "./changelog.js";
@@ -48,6 +49,26 @@ async function run() {
inputs,
});
if (inputs.mentionNewContributors) {
const { data } = await octokit.rest.repos.generateReleaseNotes({
owner,
repo,
tag_name: inputs.releaseName,
previous_tag_name: tagName,
});
const tokens = marked.lexer(data.body);
const index = tokens.findIndex(
(token) => token.type === "heading" && token.text === "New Contributors",
);
const token = tokens[index + 1];
if (token.type === "list")
changelog += `\n\n## New Contributors\n${token.raw}\n`;
}
if (inputs.includeCompare && tagName != null) {
changelog += `\n\n**Full Changelog**: https://github.com/${owner}/${repo}/compare/${tagName}...${inputs.releaseName}`;
}