Browse Source

build: fix releases that failed halfway through npm publish actions (#28854)

Co-authored-by: Samuel Attard <[email protected]>
trop[bot] 4 years ago
parent
commit
99a521ecbe
1 changed files with 7 additions and 1 deletions
  1. 7 1
      script/release/publish-to-npm.js

+ 7 - 1
script/release/publish-to-npm.js

@@ -150,7 +150,13 @@ new Promise((resolve, reject) => {
       resolve(tarballPath);
     });
   })
-  .then((tarballPath) => childProcess.execSync(`npm publish ${tarballPath} --tag ${npmTag} --otp=${process.env.ELECTRON_NPM_OTP}`))
+  .then((tarballPath) => {
+    const existingVersionJSON = childProcess.execSync(`npm view electron@${rootPackageJson.version} --json`).toString('utf-8');
+    // It's possible this is a re-run and we already have published the package, if not we just publish like normal
+    if (!existingVersionJSON) {
+      childProcess.execSync(`npm publish ${tarballPath} --tag ${npmTag} --otp=${process.env.ELECTRON_NPM_OTP}`);
+    }
+  })
   .then(() => {
     const currentTags = JSON.parse(childProcess.execSync('npm show electron dist-tags --json').toString());
     const localVersion = rootPackageJson.version;