From ac7343acf196cc9990d7bc439b45181ce0bc56f8 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Mon, 2 Oct 2023 10:50:58 +0200 Subject: [PATCH] fix: setFailed on release-it error --- README.md | 2 +- dist/index.d.ts.map | 2 +- dist/index.js | 12 ++++++++++-- dist/package.json | 2 +- src/index.ts | 16 ++++++++++------ src/release-it.d.ts | 9 ++++++++- 6 files changed, 31 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 6712ae84..19138f8c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/dist/index.d.ts.map b/dist/index.d.ts.map index c84e57c1..71e970b1 100644 --- a/dist/index.d.ts.map +++ b/dist/index.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/josh/repos/release-it-action/src/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAsB,eAAe,CAAC,EACrC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,qBAAqB,GACrB,EAAE,sBAAsB,iBA+JxB"} \ No newline at end of file +{"version":3,"file":"","sourceRoot":"","sources":["file:///Users/josh/repos/release-it-action/src/index.ts"],"names":[],"mappings":"AAQA,MAAM,WAAW,sBAAsB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,wBAAsB,eAAe,CAAC,EACrC,MAAM,EACN,YAAY,EACZ,WAAW,EACX,WAAW,EACX,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,qBAAqB,GACrB,EAAE,sBAAsB,iBAmKxB"} \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index 5ff1bd53..f30ed6c1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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}`; @@ -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, diff --git a/dist/package.json b/dist/package.json index cf5ef511..a0365718 100644 --- a/dist/package.json +++ b/dist/package.json @@ -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":"lars@webpro.nl","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"]}} \ No newline at end of file +{"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":"lars@webpro.nl","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"]}} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 9037d4f6..f93441e6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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; } @@ -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( diff --git a/src/release-it.d.ts b/src/release-it.d.ts index 73004ad6..7cab57ee 100644 --- a/src/release-it.d.ts +++ b/src/release-it.d.ts @@ -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; + ): Promise; }