From bf83ea01a2b3b148446ca2f7d4774710c28afbba Mon Sep 17 00:00:00 2001 From: Ardalan Amini Date: Sat, 19 Jun 2021 19:45:04 +0430 Subject: [PATCH] breaking: Separate `deps` type from `build` --- README.md | 3 ++- src/changelog.ts | 3 ++- src/index.ts | 54 ++++++++++++++++++++++-------------------------- 3 files changed, 29 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index da26352..d1dc639 100644 --- a/README.md +++ b/README.md @@ -13,9 +13,10 @@ type(category): description [flag] The `type` must be one of the followings: * `breaking` (Breaking Changes) -* `build` (Build System / Dependencies) +* `build` (Build System) * `ci` (Continuous Integration) * `chore` (Chores) +* `deps` (Dependencies) * `docs` (Documentation Changes) * `feat` (New Features) * `fix` (Bug Fixes) diff --git a/src/changelog.ts b/src/changelog.ts index be1de87..b68b415 100644 --- a/src/changelog.ts +++ b/src/changelog.ts @@ -105,9 +105,10 @@ const PR_REGEX = /#([1-9]\d*)/g; const TYPES = { breaking: "Breaking Changes", - build: "Build System / Dependencies", + build: "Build System", ci: "Continuous Integration", chore: "Chores", + deps: "Dependencies", docs: "Documentation Changes", feat: "New Features", fix: "Bug Fixes", diff --git a/src/index.ts b/src/index.ts index c96c5b8..818414b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,39 +1,35 @@ -import { info, getInput, setOutput, setFailed } from "@actions/core"; +import { getInput, info, setFailed, setOutput } from "@actions/core"; import { context, getOctokit } from "@actions/github"; import { generate } from "./changelog"; async function run() { - try { - const token = getInput("token", { required: true }); - const exclude = getInput("exclude", { required: false }).split(","); - const octokit = getOctokit(token); - const { - repo: { owner, repo }, - sha, - } = context; + const token = getInput("token", { required: true }); + const exclude = getInput("exclude", { required: false }).split(","); + const octokit = getOctokit(token); + const { + repo: { owner, repo }, + sha, + } = context; - const { data: tags } = await octokit.repos.listTags({ - owner, - repo, - per_page: 2, - }); + const { data: tags } = await octokit.repos.listTags({ + owner, + repo, + per_page: 2, + }); - let tagRef: string | undefined; + let tagRef: string | undefined; - if (tags.length > 0) { - if (sha === tags[0].commit.sha) { - if (tags.length > 1) tagRef = tags[1].commit.sha; - } else tagRef = tags[0].commit.sha; - } - - const changelog = await generate(octokit, exclude, owner, repo, tagRef); - - info(changelog); - - setOutput("changelog", changelog); - } catch (error) { - setFailed(error.message); + if (tags.length > 0) { + if (sha === tags[0].commit.sha) { + if (tags.length > 1) tagRef = tags[1].commit.sha; + } else tagRef = tags[0].commit.sha; } + + const changelog = await generate(octokit, exclude, owner, repo, tagRef); + + info(changelog); + + setOutput("changelog", changelog); } -run(); +run().catch((error) => setFailed(error.message));