瀏覽代碼

Backport PR #10742: More Cleanup of Automated Release Process (#10746)

Co-authored-by: Steven Silvester <steven.silvester@ieee.org>
MeeseeksMachine 3 年之前
父節點
當前提交
395c507f6b
共有 2 個文件被更改,包括 43 次插入43 次删除
  1. 0 43
      buildutils/src/prepare-python-release.ts
  2. 43 0
      buildutils/src/publish.ts

+ 0 - 43
buildutils/src/prepare-python-release.ts

@@ -9,53 +9,10 @@ import * as fs from 'fs-extra';
 import * as path from 'path';
 import * as utils from './utils';
 
-/**
- * Verify that a package specifier is published and available on npm.
- *
- * @param specifier The package specifier to verify.
- */
-function verifyPublished(specifier: string): void {
-  const cmd = `npm info ${specifier}`;
-  const output = utils.run(cmd, { stdio: 'pipe' }, true);
-  console.log(specifier);
-  if (output.indexOf('dist-tags') === -1) {
-    throw new Error(`${specifier} is not yet available`);
-  }
-}
-
-/**
- * Sleep for a specified period.
- *
- * @param wait The time in milliseconds to wait.
- */
-async function sleep(wait: number): Promise<void> {
-  return new Promise(resolve => setTimeout(resolve, wait));
-}
-
 // Specify the program signature.
 commander
   .description('Prepare the Python package for release')
   .action(async (options: any) => {
-    // Make sure all current JS packages are published.
-    console.log('Checking for published packages...');
-    utils.getCorePaths().forEach(async pkgPath => {
-      const pkgJson = path.join(pkgPath, 'package.json');
-      const pkgData = utils.readJSONFile(pkgJson);
-      const specifier = `${pkgData.name}@${pkgData.version}`;
-      let attempt = 0;
-      while (attempt < 10) {
-        try {
-          verifyPublished(specifier);
-          break;
-        } catch (e) {
-          console.error(e);
-          console.log('Sleeping for one minute...');
-          await sleep(1 * 60 * 1000);
-          attempt += 1;
-        }
-      }
-    });
-
     const distDir = './dist';
 
     // Clean the dist directory.

+ 43 - 0
buildutils/src/publish.ts

@@ -8,6 +8,29 @@ import * as path from 'path';
 import { handlePackage } from './update-dist-tag';
 import * as utils from './utils';
 
+/**
+ * Verify that a package specifier is published and available on npm.
+ *
+ * @param specifier The package specifier to verify.
+ */
+function verifyPublished(specifier: string): void {
+  const cmd = `npm info ${specifier}`;
+  const output = utils.run(cmd, { stdio: 'pipe' }, true);
+  console.log(specifier);
+  if (output.indexOf('dist-tags') === -1) {
+    throw new Error(`${specifier} is not yet available`);
+  }
+}
+
+/**
+ * Sleep for a specified period.
+ *
+ * @param wait The time in milliseconds to wait.
+ */
+async function sleep(wait: number): Promise<void> {
+  return new Promise(resolve => setTimeout(resolve, wait));
+}
+
 // Specify the program signature.
 commander
   .description('Publish the JS packages')
@@ -72,6 +95,26 @@ commander
       });
     }
 
+    // Make sure all current JS packages are published.
+    console.log('Checking for published packages...');
+    utils.getCorePaths().forEach(async pkgPath => {
+      const pkgJson = path.join(pkgPath, 'package.json');
+      const pkgData = utils.readJSONFile(pkgJson);
+      const specifier = `${pkgData.name}@${pkgData.version}`;
+      let attempt = 0;
+      while (attempt < 10) {
+        try {
+          verifyPublished(specifier);
+          break;
+        } catch (e) {
+          console.error(e);
+          console.log('Sleeping for one minute...');
+          await sleep(1 * 60 * 1000);
+          attempt += 1;
+        }
+      }
+    });
+
     // Emit a system beep.
     process.stdout.write('\x07');
   });