Sfoglia il codice sorgente

updates to release process

Steven Silvester 5 anni fa
parent
commit
5fab3f1430
5 ha cambiato i file con 64 aggiunte e 61 eliminazioni
  1. 3 2
      .bumpversion.cfg
  2. 11 20
      RELEASE.md
  3. 33 33
      buildutils/src/patch-release.ts
  4. 14 6
      buildutils/src/publish.ts
  5. 3 0
      buildutils/src/utils.ts

+ 3 - 2
.bumpversion.cfg

@@ -3,13 +3,14 @@ current_version = 2, 0, 0, 'alpha', 4
 commit = False
 tag = False
 parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \'(?P<release>\S+)\'\,\ (?P<build>\d+)
-serialize = 
+serialize =
 	{major}, {minor}, {patch}, '{release}', {build}
 
 [bumpversion:part:release]
 optional_value = final
-values = 
+values =
 	alpha
+	beta
 	candidate
 	final
 

+ 11 - 20
RELEASE.md

@@ -54,15 +54,14 @@ version, and we keep the JS versions and tags in sync with the release cycle.
 Here is an example of how version numbers progress through a release process.
 Choose and run an appropriate command to bump version numbers for this release.
 
-| Command                            | Python Version Change | NPM Version change                 |
-| ---------------------------------- | --------------------- | ---------------------------------- |
-| `jlpm bumpversion minor`           | x.y.z-> x.(y+1).0.a0  | All a.b.c -> a.(b+1).0-alpha.0     |
-| `jlpm bumpversion build`           | x.y.z.a0-> x.y.z.a1   | All a.b.c-alpha.0 -> a.b.c-alpha.1 |
-| `jlpm bumpversion release`         | x.y.z.a1-> x.y.z.rc0  | All a.b.c-alpha.1 -> a.b.c-rc.0    |
-| `jlpm bumpversion release`         | x.y.z.rc0-> x.y.z     | All a.b.c-rc0 -> a.b.c             |
-| `jlpm patch:release [...packages]` | x.y.z -> x.y.(z+1)    | Selected a.b.c -> a.b.(c+1)        |
-
-Note: if you are making a patch release, and want to update whatever JS packages changed, just do `jlpm patch:release js` (in fact, _any_ argument, not just `js`, forces all JS packages to be examined).
+| Command                    | Python Version Change | NPM Version change                 |
+| -------------------------- | --------------------- | ---------------------------------- |
+| `jlpm bumpversion minor`   | x.y.z-> x.(y+1).0.a0  | All a.b.c -> a.(b+1).0-alpha.0     |
+| `jlpm bumpversion build`   | x.y.z.a0-> x.y.z.a1   | All a.b.c-alpha.0 -> a.b.c-alpha.1 |
+| `jlpm bumpversion release` | x.y.z.a1-> x.y.z.b0   | All a.b.c-alpha.1 -> a.b.c-beta.0  |
+| `jlpm bumpversion release` | x.y.z.a1-> x.y.z.rc0  | All a.b.c-alpha.1 -> a.b.c-rc.0    |
+| `jlpm bumpversion release` | x.y.z.rc0-> x.y.z     | All a.b.c-rc0 -> a.b.c             |
+| `jlpm patch:release`       | x.y.z -> x.y.(z+1)    | Changed a.b.c -> a.b.(c+1)         |
 
 ### JS major release(s)
 
@@ -78,16 +77,10 @@ Results:
 - Python package is not affected.
 - JS dependencies are also bumped a major version.
 - Packages that have already had a major bump in this prerelease cycle are not affected.
-- All affected packages changed to match the current release type of the Python package (`alpha` or `rc`).
+- All affected packages changed to match the current release type of the Python package (`alpha`, `beta`, or `rc`).
 
 ## Publishing Packages
 
-Currently we end up with some uncommitted changes at this step. We'll need to commit them before running the publish.
-
-```bash
-git commit -am "bump version"
-```
-
 Now publish the JS packages and build the python packages
 
 ```bash
@@ -109,11 +102,9 @@ IntSlider()
 
 ## Finish
 
-Follow instructions printed at the end of the publish step above, including:
+Follow instructions printed at the end of the publish step above:
 
-- committing changes
-- tagging the release
-- and uploading to pypi with twine
+- upload to pypi with twine
 - double-check what branch you are on, then push changes to the correct upstream branch with the `--tags` option.
 
 ## Post release candidate checklist

+ 33 - 33
buildutils/src/patch-release.ts

@@ -8,48 +8,48 @@ import * as utils from './utils';
 
 // Specify the program signature.
 commander
-  .description('Create a patch release with optional patch JS releases')
-  .arguments('[pkgs...]')
+  .description('Create a patch release')
   .option('--force', 'Force the upgrade')
-  .action((pkgNames: Array<string>, options: any) => {
+  .action((options: any) => {
     // Make sure we can patch release.
     const pyVersion = utils.getPythonVersion();
-    if (pyVersion.includes('a') || pyVersion.includes('rc')) {
+    if (
+      pyVersion.includes('a') ||
+      pyVersion.includes('b') ||
+      pyVersion.includes('rc')
+    ) {
       throw new Error('Can only make a patch release from a final version');
     }
 
     // Run pre-bump actions.
     utils.prebump();
 
-    // Version the desired packages
-    const pkgs = pkgNames.join(',');
-    if (pkgs) {
-      let cmd = `lerna version patch -m \"New version\" --force-publish=${pkgs} --no-push`;
-      if (options.force) {
-        cmd += ' --yes';
-      }
-      let oldVersion = utils.run(
-        'git rev-parse HEAD',
-        {
-          stdio: 'pipe',
-          encoding: 'utf8'
-        },
-        true
-      );
-      utils.run(cmd);
-      let newVersion = utils.run(
-        'git rev-parse HEAD',
-        {
-          stdio: 'pipe',
-          encoding: 'utf8'
-        },
-        true
-      );
-      if (oldVersion === newVersion) {
-        console.log('aborting');
-        // lerna didn't version anything, so we assume the user aborted
-        throw new Error('Lerna aborted');
-      }
+    // Version the changed
+    let cmd = `lerna version patch -m \"New version\" --no-push`;
+    if (options.force) {
+      cmd += ' --yes';
+    }
+    let oldVersion = utils.run(
+      'git rev-parse HEAD',
+      {
+        stdio: 'pipe',
+        encoding: 'utf8'
+      },
+      true
+    );
+    utils.run(cmd);
+    let newVersion = utils.run(
+      'git rev-parse HEAD',
+      {
+        stdio: 'pipe',
+        encoding: 'utf8'
+      },
+      true
+    );
+    if (oldVersion === newVersion) {
+      console.log('aborting');
+      // lerna didn't version anything, so we assume the user aborted
+      throw new Error('Lerna aborted');
     }
 
     // Patch the python version

+ 14 - 6
buildutils/src/publish.ts

@@ -22,11 +22,17 @@ commander
     if (utils.checkStatus('npm whoami') !== 0) {
       console.error('Please run `npm login`');
     }
+    const distDir = './dist';
 
     // Optionally clean and build the python packages.
     if (!options.skipBuild) {
       // Ensure a clean state.
       utils.run('npm run clean:slate');
+    } else {
+      // Still clean the dist directory.
+      if (fs.existsSync(distDir)) {
+        fs.removeSync(distDir);
+      }
     }
 
     // Publish JS to the appropriate tag.
@@ -57,11 +63,11 @@ commander
     utils.run('python -m pip install -U twine');
     utils.run('twine check dist/*');
 
-    const files = fs.readdirSync('./dist/');
+    const files = fs.readdirSync(distDir);
     const hashes = new Map<string, string>();
     files.forEach(file => {
       const shasum = crypto.createHash('sha256');
-      const hash = shasum.update(fs.readFileSync('./dist/' + file));
+      const hash = shasum.update(fs.readFileSync(path.join(distDir, file)));
       hashes.set(file, hash.digest('hex'));
     });
 
@@ -69,15 +75,17 @@ commander
       .map(entry => `${entry[0]}: ${entry[1]}`)
       .join('" -m "');
 
+    // Make the commit and the tag.
+    utils.run(
+      `git commit -am "Publish ${curr}" -m "SHA256 hashes:" -m "${hashString}"`
+    );
+    utils.run(`git tag v${curr}`);
+
     // Prompt the user to finalize.
     console.log('*'.repeat(40));
     console.log('*'.repeat(40));
     console.log('Ready to publish!');
     console.log('Run these command when ready:');
-    console.log(
-      `git commit -am "Publish ${curr}" -m "SHA256 hashes:" -m "${hashString}"`
-    );
-    console.log(`git tag v${curr}`);
     console.log('twine upload dist/*');
     console.log('git push origin <BRANCH> --tags');
   });

+ 3 - 0
buildutils/src/utils.ts

@@ -224,6 +224,9 @@ export function postbump() {
   let data = readJSONFile(filePath);
   data.jupyterlab.version = curr;
   writeJSONFile(filePath, data);
+
+  // Commit changes.
+  run('git commit -am "bump version"');
 }
 
 /**