From c6fc5a23fcaf14a9a5eac27e9b0a1ad873f89683 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Wed, 6 Feb 2019 16:51:45 -0800 Subject: [PATCH] Revert "build: hack around GitHub upload API failure / flake (#16663)" (#16802) This reverts commit ab503c7e4349315f600ac3c49b43bab6f88b6f54. --- script/upload-to-github.js | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/script/upload-to-github.js b/script/upload-to-github.js index cd5515be7f96..6c517aa9d22c 100644 --- a/script/upload-to-github.js +++ b/script/upload-to-github.js @@ -36,28 +36,17 @@ const uploadUrl = `https://uploads.github.com/repos/electron/${targetRepo}/relea let retry = 0 function uploadToGitHub () { - const fakeFileNamePrefix = `fake-${fileName}-fake-` - const fakeFileName = `${fakeFileNamePrefix}${Date.now()}` - octokit.repos.uploadReleaseAsset({ url: uploadUrl, headers: getHeaders(filePath, fileName), file: fs.createReadStream(filePath), - name: fakeFileName - }).then((uploadResponse) => { - console.log(`Successfully uploaded ${fileName} to GitHub as ${fakeFileName}. Going for the rename now.`) - return octokit.repos.updateReleaseAsset({ - owner: 'electron', - repo: 'electron', - asset_id: uploadResponse.data.id, - name: fileName - }).then(() => { - console.log(`Successfully renamed ${fakeFileName} to ${fileName}. All done now.`) - process.exit(0) - }) + name: fileName + }).then(() => { + console.log(`Successfully uploaded ${fileName} to GitHub.`) + process.exit() }).catch((err) => { if (retry < 4) { - console.log(`Error uploading ${fileName} as ${fakeFileName} to GitHub, will retry. Error was:`, err) + console.log(`Error uploading ${fileName} to GitHub, will retry. Error was:`, err) retry++ octokit.repos.listAssetsForRelease({ @@ -67,17 +56,15 @@ function uploadToGitHub () { }).then(assets => { console.log('Got list of assets for existing release:') console.log(JSON.stringify(assets.data, null, ' ')) - const existingAssets = assets.data.filter(asset => asset.name.startsWith(fakeFileNamePrefix) || asset.name === fileName) + const existingAssets = assets.data.filter(asset => asset.name === fileName) if (existingAssets.length > 0) { console.log(`${fileName} already exists; will delete before retrying upload.`) - Promise.all( - existingAssets.map(existingAsset => octokit.repos.deleteReleaseAsset({ - owner: 'electron', - repo: targetRepo, - asset_id: existingAsset.id - })) - ).catch((deleteErr) => { + octokit.repos.deleteReleaseAsset({ + owner: 'electron', + repo: targetRepo, + asset_id: existingAssets[0].id + }).catch((deleteErr) => { console.log(`Failed to delete existing asset ${fileName}. Error was:`, deleteErr) }).then(uploadToGitHub) } else {