Skip to content

Commit

Permalink
fix: setFailed on release-it error
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaKGoldberg committed Oct 2, 2023
1 parent eff8aa1 commit ac7343a
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
- env:
GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
uses: JoshuaKGoldberg/release-it-action@v0.1.0
uses: JoshuaKGoldberg/release-it-action@v0.2.0

name: Release

Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -337005,7 +337005,7 @@ async function tryCatchInfoAction(label, action) {


async function releaseItAction({ branch, gitUserEmail, gitUserName, githubToken, npmToken, owner, repo, skipBranchProtections, }) {
if (!(await tryCatchInfoAction("should-semantic-release", async () => await shouldSemanticRelease_shouldSemanticRelease({ verbose: true })))) {
if ((await tryCatchInfoAction("should-semantic-release", async () => await shouldSemanticRelease_shouldSemanticRelease({ verbose: true }))) === false) {
return;
}
await $ `git config user.email ${gitUserEmail}`;
Expand All @@ -337029,7 +337029,15 @@ async function releaseItAction({ branch, gitUserEmail, gitUserName, githubToken,
else {
core.info(`No existing branch protections found for ${branch}.`);
}
await tryCatchInfoAction("running release-it", async () => await release_it_lib({ verbose: true }));
await tryCatchInfoAction("running release-it", async () => {
try {
await release_it_lib({ verbose: true });
}
catch (error) {
core.error(`Error running release-it: ${error}`);
core.setFailed(error);
}
});
if (existingProtections) {
await tryCatchInfoAction("re-creating branch protections", async () => await octokit.request(`PUT /repos/{owner}/{repo}/branches/{branch}/protection`, {
...commonRequestData,
Expand Down
2 changes: 1 addition & 1 deletion dist/package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"name":"release-it","version":"16.2.1","description":"Generic CLI tool to automate versioning and package publishing-related tasks.","keywords":["build","changelog","commit","distribution","git","github","gitlab","interactive","ci","npm","publish","push","release","release-it","repository","script","shell","tag","tool","version","semver","plugin"],"repository":{"type":"git","url":"https://github.com/release-it/release-it.git"},"homepage":"https://github.com/release-it/release-it#readme","bugs":"https://github.com/release-it/release-it/issues","bin":{"release-it":"bin/release-it.js"},"type":"module","exports":{".":"./lib/index.js","./package.json":"./package.json","./test/util/index.js":"./test/util/index.js"},"files":["bin","config","lib","test"],"scripts":{"knip":"knip","lint":"eslint lib test","format":"prettier --write \"{lib,test}/**/*.js\"","docs":"remark README.md 'docs/**/*.md' '.github/*.md' -o","test":"ava --no-worker-threads","release":"./bin/release-it.js"},"author":{"email":"[email protected]","name":"Lars Kappert"},"license":"MIT","dependencies":{"@iarna/toml":"2.2.5","@octokit/rest":"19.0.13","async-retry":"1.3.3","chalk":"5.3.0","cosmiconfig":"8.3.6","execa":"7.2.0","git-url-parse":"13.1.0","globby":"13.2.2","got":"13.0.0","inquirer":"9.2.11","is-ci":"3.0.1","issue-parser":"6.0.0","lodash":"4.17.21","mime-types":"2.1.35","new-github-release-url":"2.0.0","node-fetch":"3.3.2","open":"9.1.0","ora":"7.0.1","os-name":"5.1.0","promise.allsettled":"1.0.7","proxy-agent":"6.3.1","semver":"7.5.4","shelljs":"0.8.5","update-notifier":"6.0.2","url-join":"5.0.0","wildcard-match":"5.1.2","yargs-parser":"21.1.1"},"devDependencies":{"@octokit/request-error":"3.0.3","ava":"5.3.1","eslint":"8.50.0","eslint-config-prettier":"9.0.0","eslint-plugin-ava":"14.0.0","eslint-plugin-import":"2.28.1","eslint-plugin-prettier":"5.0.0","fs-monkey":"1.0.5","knip":"2.30.0","memfs":"4.5.0","mock-stdio":"1.0.3","nock":"13.3.3","prettier":"3.0.3","remark-cli":"11.0.0","remark-preset-webpro":"0.0.3","sinon":"16.0.0","strip-ansi":"7.1.0"},"overrides":{"@octokit/plugin-rest-endpoint-methods":"10.0.0"},"engines":{"node":">=16"},"remarkConfig":{"plugins":["preset-webpro"]}}
{"name":"release-it","version":"16.2.1","description":"Generic CLI tool to automate versioning and package publishing-related tasks.","keywords":["build","changelog","commit","distribution","git","github","gitlab","interactive","ci","npm","publish","push","release","release-it","repository","script","shell","tag","tool","version","semver","plugin"],"repository":{"type":"git","url":"https://github.com/release-it/release-it.git"},"homepage":"https://github.com/release-it/release-it#readme","bugs":"https://github.com/release-it/release-it/issues","bin":{"release-it":"bin/release-it.js"},"type":"module","exports":{".":"./lib/index.js","./package.json":"./package.json","./test/util/index.js":"./test/util/index.js"},"files":["bin","config","lib","test"],"scripts":{"knip":"knip","lint":"eslint lib test","format":"prettier --write \"{lib,test}/**/*.js\"","docs":"remark README.md 'docs/**/*.md' '.github/*.md' -o","test":"ava --no-worker-threads","release":"./bin/release-it.js"},"author":{"email":"[email protected]","name":"Lars Kappert"},"license":"MIT","dependencies":{"@iarna/toml":"2.2.5","@octokit/rest":"19.0.13","async-retry":"1.3.3","chalk":"5.3.0","cosmiconfig":"8.3.6","execa":"7.2.0","git-url-parse":"13.1.0","globby":"13.2.2","got":"13.0.0","inquirer":"9.2.11","is-ci":"3.0.1","issue-parser":"6.0.0","lodash":"4.17.21","mime-types":"2.1.35","new-github-release-url":"2.0.0","node-fetch":"3.3.2","open":"9.1.0","ora":"7.0.1","os-name":"5.1.0","promise.allsettled":"1.0.7","proxy-agent":"6.3.1","semver":"7.5.4","shelljs":"0.8.5","update-notifier":"6.0.2","url-join":"5.0.0","wildcard-match":"5.1.2","yargs-parser":"21.1.1"},"devDependencies":{"@octokit/request-error":"3.0.3","ava":"5.3.1","eslint":"8.50.0","eslint-config-prettier":"9.0.0","eslint-plugin-ava":"14.0.0","eslint-plugin-import":"2.28.1","eslint-plugin-prettier":"5.0.0","fs-monkey":"1.0.5","knip":"2.29.0","memfs":"4.5.0","mock-stdio":"1.0.3","nock":"13.3.3","prettier":"3.0.3","remark-cli":"11.0.0","remark-preset-webpro":"0.0.3","sinon":"16.0.0","strip-ansi":"7.1.0"},"overrides":{"@octokit/plugin-rest-endpoint-methods":"7.2.2"},"engines":{"node":">=16"},"remarkConfig":{"plugins":["preset-webpro"]}}
16 changes: 10 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ export async function releaseItAction({
skipBranchProtections,
}: ReleaseItActionOptions) {
if (
!(await tryCatchInfoAction(
(await tryCatchInfoAction(
"should-semantic-release",
async () => await shouldSemanticRelease({ verbose: true }),
))
)) === false
) {
return;
}
Expand Down Expand Up @@ -74,10 +74,14 @@ export async function releaseItAction({
core.info(`No existing branch protections found for ${branch}.`);
}

await tryCatchInfoAction(
"running release-it",
async () => await releaseIt({ verbose: true }),
);
await tryCatchInfoAction("running release-it", async () => {
try {
await releaseIt({ verbose: true });
} catch (error) {
core.error(`Error running release-it: ${error as string}`);
core.setFailed(error as string);
}
});

if (existingProtections) {
await tryCatchInfoAction(
Expand Down
9 changes: 8 additions & 1 deletion src/release-it.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@ declare module "release-it" {
verbose?: boolean;
}

export interface ReleaseItResult {
changelog: string;
latestVersion: string;
name: string;
version: string;
}

export default function releaseIt(
options?: ReleaseItOptions,
): Promise<unknown>;
): Promise<ReleaseItResult>;
}

0 comments on commit ac7343a

Please sign in to comment.