Browse Source

Undo (#16690)

* Revert "fix asset fail workaround (#16680)"

This reverts commit e61c8543f1262d155b402edc7988c3cf9cbcdb8d.

* Revert "build: hack around GitHub upload API failure / flake (#16667)"

This reverts commit 1098d0f41487b5aad4ba7451dd2f88d4dc86395c.
Shelley Vohr 6 years ago
parent
commit
0dd8fd57de
1 changed files with 18 additions and 30 deletions
  1. 18 30
      script/upload-to-github.js

+ 18 - 30
script/upload-to-github.js

@@ -15,47 +15,35 @@ const releaseVersion = process.argv[5]
 
 const targetRepo = releaseVersion.indexOf('nightly') > 0 ? 'nightlies' : 'electron'
 
+const githubOpts = {
+  owner: 'electron',
+  repo: targetRepo,
+  id: releaseId,
+  filePath: filePath,
+  name: fileName
+}
+
 let retry = 0
 
 function uploadToGitHub () {
-  const fakeFileNamePrefix = `fake-${fileName}-fake-`
-  const fakeFileName = `${fakeFileNamePrefix}${Date.now()}`
-  const githubOpts = {
-    owner: 'electron',
-    repo: targetRepo,
-    id: releaseId,
-    filePath: filePath,
-    name: fakeFileName
-  }
-
-  github.repos.uploadAsset(githubOpts).then((uploadResponse) => {
-    console.log(`Successfully uploaded ${fileName} to GitHub as ${fakeFileName}. Going for the rename now.`)
-    return github.repos.editAsset({
-      owner: 'electron',
-      repo: 'electron',
-      id: uploadResponse.data.id,
-      name: fileName
-    }).then(() => {
-      console.log(`Successfully renamed ${fakeFileName} to ${fileName}. All done now.`)
-      process.exit(0)
-    })
+  github.repos.uploadAsset(githubOpts).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++
       github.repos.getRelease(githubOpts).then(release => {
         console.log('Got list of assets for existing release:')
         console.log(JSON.stringify(release.data.assets, null, '  '))
-        const existingAssets = release.data.assets.filter(asset => asset.name.startsWith(fakeFileNamePrefix) || asset.name === fileName)
+        const existingAssets = release.data.assets.filter(asset => asset.name === fileName)
         if (existingAssets.length > 0) {
           console.log(`${fileName} already exists; will delete before retrying upload.`)
-          Promise.all(
-            existingAssets.map(existingAsset => github.repos.deleteAsset({
-              owner: 'electron',
-              repo: targetRepo,
-              id: existingAsset.id
-            }))
-          ).catch((deleteErr) => {
+          github.repos.deleteAsset({
+            owner: 'electron',
+            repo: targetRepo,
+            id: existingAssets[0].id
+          }).catch((deleteErr) => {
             console.log(`Failed to delete existing asset ${fileName}.  Error was:`, deleteErr)
           }).then(uploadToGitHub)
         } else {