diff --git a/.changeset/bright-trees-pump.md b/.changeset/bright-trees-pump.md new file mode 100644 index 0000000..3f102b2 --- /dev/null +++ b/.changeset/bright-trees-pump.md @@ -0,0 +1,5 @@ +--- +"changeset-release": patch +--- + +Added error handling for failed `createRelease` using `octokit`. diff --git a/src/index.ts b/src/index.ts index b281dd1..da00cb0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -67,12 +67,19 @@ async function main() { const tagName = `v${version}` const { content } = getChangelogEntry(changelog, version) - await octokit.rest.repos.createRelease({ - body: content, - name: tagName, - tag_name: tagName, - ...github.context.repo, - }) + try { + await octokit.rest.repos.createRelease({ + body: content, + name: tagName, + tag_name: tagName, + ...github.context.repo, + }) + } catch (error) { + core.error(error as string) + core.setFailed( + "Failed create release. Please make sure 'contents: write' permission is granted to job.", + ) + } core.setOutput("tag", tagName) } catch (error) {