feat: Use generate-changelog package

This commit is contained in:
Ardalan Amini committed 2020-09-28 15:46:55 +03:30
1 parent 886408e12f
commit 22d355a83e
6 files changed
+149 -10

No files matched your search

+36 -7
View File
@@ -1,12 +1,41 @@
import { info, getInput, setOutput, setFailed } from "@actions/core";
import { context } from "@actions/github";
import { context, getOctokit } from "@actions/github";
import Changelog from "generate-changelog";
try {
const token = getInput("token", { required: true });
async function run() {
try {
const token = getInput("token", { required: true });
const octokit = getOctokit(token);
const {
repo: { owner, repo },
sha,
} = context;
info(JSON.stringify(context.repo));
const { data: tags } = await octokit.repos.listTags({
owner,
repo,
per_page: 2,
});
setOutput("changelog", "Changelog");
} catch (error) {
setFailed(error.message);
let tag: string | undefined;
if (tags.length > 0) {
if (sha === tags[0].commit.sha) {
if (tags.length > 1) tag = tags[1].name;
} else tag = tags[0].name;
}
const changelog = await Changelog.generate({
repoUrl: `https://github.com/${owner}/${repo}`,
tag,
});
info(changelog);
setOutput("changelog", changelog);
} catch (error) {
setFailed(error.message);
}
}
run();