publish.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*-----------------------------------------------------------------------------
  2. | Copyright (c) Jupyter Development Team.
  3. | Distributed under the terms of the Modified BSD License.
  4. |----------------------------------------------------------------------------*/
  5. import commander from 'commander';
  6. import * as path from 'path';
  7. import { handlePackage } from './update-dist-tag';
  8. import * as utils from './utils';
  9. // Specify the program signature.
  10. commander
  11. .description('Publish the JS packages and prep the Python package')
  12. .option(
  13. '--skip-build',
  14. 'Skip the clean and build step (if there was a network error during a JS publish'
  15. )
  16. .action(async (options: any) => {
  17. // Make sure we are logged in.
  18. if (utils.checkStatus('npm whoami') !== 0) {
  19. console.error('Please run `npm login`');
  20. }
  21. // Optionally clean and build the python packages.
  22. if (!options.skipBuild) {
  23. // Ensure a clean state.
  24. utils.run('npm run clean:slate');
  25. }
  26. // Publish JS to the appropriate tag.
  27. const curr = utils.getPythonVersion();
  28. if (curr.indexOf('rc') === -1 && curr.indexOf('a') === -1) {
  29. utils.run('lerna publish from-package -m "Publish"');
  30. } else {
  31. utils.run('lerna publish from-package --npm-tag=next -m "Publish"');
  32. }
  33. // Fix up any tagging issues.
  34. const basePath = path.resolve('.');
  35. const paths = utils.getLernaPaths(basePath).sort();
  36. const cmds = await Promise.all(paths.map(handlePackage));
  37. cmds.forEach(cmdList => {
  38. cmdList.forEach(cmd => {
  39. utils.run(cmd);
  40. });
  41. });
  42. // Update core mode. This cannot be done until the JS packages are
  43. // released.
  44. utils.run('node buildutils/lib/update-core-mode.js');
  45. // Make the Python release.
  46. utils.run('python setup.py sdist');
  47. utils.run('python setup.py bdist_wheel');
  48. utils.run('python -m pip install -U twine');
  49. utils.run('twine check dist/*');
  50. // Prompt the user to finalize.
  51. console.log('*'.repeat(40));
  52. console.log('Ready to publish!');
  53. console.log('Run these command when ready:');
  54. console.log(`git tag v${curr}`);
  55. console.log(`git commit -am "Publish ${curr}"`);
  56. console.log('twine upload dist/*');
  57. });
  58. commander.parse(process.argv);