From e197e56931612828bb1e082098c96e4b76e6e5f0 Mon Sep 17 00:00:00 2001 From: softprops Date: Mon, 9 Sep 2019 20:46:36 +0900 Subject: [PATCH] try try try again --- lib/github.js | 32 +++++++++++++++++++------------- src/github.ts | 31 ++++++++++++++++++------------- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/lib/github.js b/lib/github.js index 614f7bf..9544515 100644 --- a/lib/github.js +++ b/lib/github.js @@ -49,19 +49,25 @@ exports.release = (config, gh) => __awaiter(void 0, void 0, void 0, function* () catch (error) { if (error.status === 404) { console.log("Creating new release..."); - const tag_name = config.github_ref.replace("refs/tags/", ""); - const name = config.input_name || tag_name; - const body = config.input_body; - const draft = config.input_draft; - let release = yield gh.repos.createRelease({ - owner, - repo, - tag_name, - name, - body, - draft - }); - return release.data; + try { + const tag_name = config.github_ref.replace("refs/tags/", ""); + const name = config.input_name || tag_name; + const body = config.input_body; + const draft = config.input_draft; + let release = yield gh.repos.createRelease({ + owner, + repo, + tag_name, + name, + body, + draft + }); + return release.data; + } + catch (error) { + console.log(`created failed with status: ${error.status}`); + return exports.release(config, gh); + } } else { console.log(`Unexpected error fetching github release for tag ${config.github_ref}: ${error}`); diff --git a/src/github.ts b/src/github.ts index 2bb9e1f..f46e48c 100644 --- a/src/github.ts +++ b/src/github.ts @@ -67,19 +67,24 @@ export const release = async ( } catch (error) { if (error.status === 404) { console.log("Creating new release..."); - const tag_name = config.github_ref.replace("refs/tags/", ""); - const name = config.input_name || tag_name; - const body = config.input_body; - const draft = config.input_draft; - let release = await gh.repos.createRelease({ - owner, - repo, - tag_name, - name, - body, - draft - }); - return release.data; + try { + const tag_name = config.github_ref.replace("refs/tags/", ""); + const name = config.input_name || tag_name; + const body = config.input_body; + const draft = config.input_draft; + let release = await gh.repos.createRelease({ + owner, + repo, + tag_name, + name, + body, + draft + }); + return release.data; + } catch (error) { + console.log(`created failed with status: ${error.status}`); + return release(config, gh); + } } else { console.log(`Unexpected error fetching github release for tag ${config.github_ref}: ${error}`); throw error;