From 54563dc94ccb1aea8a29b22739eff309bca21bbc Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Wed, 4 Oct 2017 10:33:27 -0400 Subject: [PATCH 1/2] Add logic to retry github uploads When doing release, sometimes the GitHub upload fails, so try to retry it once before bailing. --- script/upload-to-github.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/script/upload-to-github.js b/script/upload-to-github.js index 82374ef49b65..0308b84a43df 100644 --- a/script/upload-to-github.js +++ b/script/upload-to-github.js @@ -13,9 +13,22 @@ let githubOpts = { filePath: filePath, name: fileName } -github.repos.uploadAsset(githubOpts).then(() => { - process.exit() -}).catch((err) => { - console.log(`Error uploading ${fileName} to GitHub:`, err) - process.exitCode = 1 -}) + +let retry = true + +function uploadToGitHub () { + github.repos.uploadAsset(githubOpts).then(() => { + process.exit() + }).catch((err) => { + if (retry) { + console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err) + retry = false + uploadToGitHub() + } else { + console.log(`Error retrying uploading ${fileName} to GitHub:`, err) + process.exitCode = 1 + } + }) +} + +uploadToGitHub() From 0ae12c2b3d4888afd89c49bd9f77a8738d2c967c Mon Sep 17 00:00:00 2001 From: John Kleinschmidt Date: Thu, 5 Oct 2017 16:31:54 -0400 Subject: [PATCH 2/2] Add success message Also increase retries to 5 attempts. --- script/upload-to-github.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/script/upload-to-github.js b/script/upload-to-github.js index 0308b84a43df..45b82a285b27 100644 --- a/script/upload-to-github.js +++ b/script/upload-to-github.js @@ -2,6 +2,10 @@ const GitHub = require('github') const github = new GitHub() github.authenticate({type: 'token', token: process.env.ELECTRON_GITHUB_TOKEN}) +if (process.argv.length < 5) { + console.log('Usage: upload-to-github filePath fileName releaseId') + process.exit(1) +} let filePath = process.argv[2] let fileName = process.argv[3] let releaseId = process.argv[4] @@ -14,15 +18,16 @@ let githubOpts = { name: fileName } -let retry = true +let retry = 0 function uploadToGitHub () { github.repos.uploadAsset(githubOpts).then(() => { + console.log(`Successfully uploaded ${fileName} to GitHub.`) process.exit() }).catch((err) => { - if (retry) { + if (retry < 4) { console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err) - retry = false + retry++ uploadToGitHub() } else { console.log(`Error retrying uploading ${fileName} to GitHub:`, err)