mirror of
https://github.com/darksaid98/auto-changelog.git
synced 2026-12-02 22:16:06 +00:00
feat: Use generate-changelog package
This commit is contained in:
6 files changed
+149
-10
No files matched your search
+36
-7
@@ -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();
|
||||
Reference in new issue
Block a user