Jelajahi Sumber

more release cleanup

Steven Silvester 5 tahun lalu
induk
melakukan
a3d6c94535
2 mengubah file dengan 57 tambahan dan 40 penghapusan
  1. 2 1
      RELEASE.md
  2. 55 39
      buildutils/src/publish.ts

+ 2 - 1
RELEASE.md

@@ -73,7 +73,8 @@ JupyterLab itself, run `jlpm run bumpversion major`.
 - Push the commits and tags as prompted.
 - Run `jlpm run publish:all` to publish the JS and Python packages.
   Execute the suggested commands after doing a quick sanity check.
-
+  If there is a network error during JS publish, run `jlpm run publish:all --skip-build` to resume publish without requiring another
+  clean and build phase of the JS packages.
 - Run `jlpm run bumpversion release` to switch to an `rc` version.
   (running `jlpm run bumpversion build` will then increment `rc` versions).
 

+ 55 - 39
buildutils/src/publish.ts

@@ -3,49 +3,65 @@
 | Distributed under the terms of the Modified BSD License.
 |----------------------------------------------------------------------------*/
 
+import commander from 'commander';
 import * as path from 'path';
 import { handlePackage } from './update-dist-tag';
 import * as utils from './utils';
 
-async function main() {
-  // Ensure a clean state.
-  utils.run('jlpm run clean:slate');
-
-  // Publish JS to the appropriate tag.
-  const curr = utils.getPythonVersion();
-  if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
-    utils.run('lerna publish from-package -m "Publish"');
-  } else {
-    utils.run('lerna publish from-package --npm-tag=next -m "Publish"');
-  }
-
-  // Fix up any tagging issues.
-  const basePath = path.resolve('.');
-  const paths = utils.getLernaPaths(basePath).sort();
-  const cmds = await Promise.all(paths.map(handlePackage));
-  cmds.forEach(cmdList => {
-    cmdList.forEach(cmd => {
-      utils.run(cmd);
+// Specify the program signature.
+commander
+  .description('Publish the JS packages and prep the Python package')
+  .option(
+    '--skip-build',
+    'Skip the clean and build step (if there was a network error during a JS publish'
+  )
+  .action(async (options: any) => {
+    // Make sure we are logged in.
+    if (utils.checkStatus('npm whoami') !== 0) {
+      console.error('Please run `npm login`');
+    }
+
+    // Optionally clean and build the python packages.
+    if (!options.skipBuild) {
+      // Ensure a clean state.
+      utils.run('jlpm run clean:slate');
+    }
+
+    // Publish JS to the appropriate tag.
+    const curr = utils.getPythonVersion();
+    if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
+      utils.run('lerna publish from-package -m "Publish"');
+    } else {
+      utils.run('lerna publish from-package --npm-tag=next -m "Publish"');
+    }
+
+    // Fix up any tagging issues.
+    const basePath = path.resolve('.');
+    const paths = utils.getLernaPaths(basePath).sort();
+    const cmds = await Promise.all(paths.map(handlePackage));
+    cmds.forEach(cmdList => {
+      cmdList.forEach(cmd => {
+        utils.run(cmd);
+      });
     });
+
+    // Update core mode.  This cannot be done until the JS packages are
+    // released.
+    utils.run('node buildutils/lib/update-core-mode.js');
+
+    // Make the Python release.
+    utils.run('python setup.py sdist');
+    utils.run('python setup.py bdist_wheel');
+    utils.run('python -m pip install -U twine');
+    utils.run('twine check dist/*');
+
+    // Prompt the user to finalize.
+    console.log('*'.repeat(40));
+    console.log('Ready to publish!');
+    console.log('Run these command when ready:');
+    console.log(`git tag v${curr}`);
+    console.log(`git commit -am "Publish ${curr}"`);
+    console.log('twine upload dist/*');
   });
 
-  // Update core mode.  This cannot be done until the JS packages are
-  // released.
-  utils.run('node buildutils/lib/update-core-mode.js');
-
-  // Make the Python release.
-  utils.run('python setup.py sdist');
-  utils.run('python setup.py bdist_wheel');
-  utils.run('python -m pip install -U twine');
-  utils.run('twine check dist/*');
-
-  // Prompt the user to finalize.
-  console.log('*'.repeat(40));
-  console.log('Ready to publish!');
-  console.log('Run these command when ready:');
-  console.log(`git tag v${curr}`);
-  console.log(`git commit -am "Publish ${curr}"`);
-  console.log('twine upload dist/*');
-}
-
-void main();
+commander.parse(process.argv);