From 978cf0553a2bc44f250cf839c74b79f95fb8edaa Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 3 Jul 2018 17:36:56 -0400 Subject: [PATCH 01/20] Fix prepare-platform-release-branch usage --- src/platform-release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/platform-release.js b/src/platform-release.js index 9982c3291..d86457304 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -197,7 +197,7 @@ exports.prepareReleaseBranchCommand = function * () { 'Command can also be used to update the JS snapshot after release \n' + 'branches have been created.\n' + '\n' + - 'Usage: $0 prepare-release-branch -r platform [--version=3.6.0]') + 'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0]') ); var repos = flagutil.computeReposFromFlag(argv.r); From 7b54e2752305a3b833885bb94fb915b0c038a3c8 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 3 Jul 2018 17:32:36 -0400 Subject: [PATCH 02/20] Prepare CDVAvailability.h after updating JS --- src/platform-release.js | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index d86457304..167fa6699 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -214,14 +214,7 @@ exports.prepareReleaseBranchCommand = function * () { yield gitutil.stashAndPop(repo, function * () { // git fetch + update master yield repoupdate.updateRepos([repo], ['master'], false); - if (platform === 'ios') { - // Updates version in CDVAvailability.h file - yield updateCDVAvailabilityFile(version); - // Git commit changes - if (yield gitutil.pendingChangesExist()) { - yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).')); - } - } + // Either create or pull down the branch. if (yield gitutil.remoteBranchExists(repo, branchName)) { print('Remote branch already exists for repo: ' + repo.repoName); @@ -236,9 +229,19 @@ exports.prepareReleaseBranchCommand = function * () { } yield updateJsSnapshot(repo, version, true); + print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + branchName + '".'); yield versionutil.updateRepoVersion(repo, version); + if (platform === 'ios') { + // Updates version in CDVAvailability.h file + yield updateCDVAvailabilityFile(version); + // Git commit changes + if (yield gitutil.pendingChangesExist()) { + yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).')); + } + } + yield gitutil.gitCheckout('master'); var devVersion = createPlatformDevVersion(version); print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".'); From aefb169daa57f3931b08aa8ea63866dcd58117ba Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 3 Jul 2018 17:33:09 -0400 Subject: [PATCH 03/20] Additional output for prepare-platform-release-branch --- src/platform-release.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform-release.js b/src/platform-release.js index 167fa6699..f400ac8d2 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -228,6 +228,7 @@ exports.prepareReleaseBranchCommand = function * () { yield executil.execHelper(executil.ARGS('git checkout -b ' + branchName)); } + print(repo.repoName + ': Update JS snapshot version for VERSION "' + version + '" on branch "' + branchName + '".'); yield updateJsSnapshot(repo, version, true); print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + branchName + '".'); @@ -235,6 +236,7 @@ exports.prepareReleaseBranchCommand = function * () { if (platform === 'ios') { // Updates version in CDVAvailability.h file + print(repo.repoName + ': Update CDVAvailability.h for VERSION to "' + version + '" on branch "' + branchName + '".'); yield updateCDVAvailabilityFile(version); // Git commit changes if (yield gitutil.pendingChangesExist()) { From 0b715dc7aca1e3183bd59a4da7cc44718a55c6b2 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Thu, 21 Jun 2018 21:48:53 -0400 Subject: [PATCH 04/20] WORKAROUND for local grunt issue in cordova-js --- src/platform-release.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/platform-release.js b/src/platform-release.js index f400ac8d2..b53ccf0b0 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -142,7 +142,9 @@ function * updateJsSnapshot (repo, version, commit) { // git fetch and update master for cordovajs yield repoupdate.updateRepos([cordovaJsRepo], ['master'], false); yield gitutil.gitCheckout('master'); + yield executil.execHelper(executil.ARGS('npm install'), false, true); // WORKAROUND PART 1 for local grunt issue in cordova-js yield executil.execHelper(executil.ARGS('grunt compile:' + repo.id + ' --platformVersion=' + version), false, true); + shelljs.rm('-fr', 'node_modules'); // WORKAROUND PART 2 for local grunt issue in cordova-js hasBuiltJs = version; }); }); From a4110226b5e5ad9f36a1782dd8ca972870c0f0cb Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 3 Jul 2018 19:23:02 -0400 Subject: [PATCH 05/20] Updates to improve support for patch releases - prepare-platform-release-branch add options: - [-b ] - [--js ] - copy-js add option: - [--js ] --- src/platform-release.js | 68 ++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index b53ccf0b0..39df2318c 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -130,7 +130,7 @@ function * updateCDVAvailabilityFile (version) { fs.writeFileSync(iosFile, iosFileContents.join('\n')); } -function * updateJsSnapshot (repo, version, commit) { +function * updateJsSnapshot (repo, version, commit, branch) { function * ensureJsIsBuilt () { var cordovaJsRepo = repoutil.getRepoById('js'); if (repo.id === 'blackberry') { @@ -139,9 +139,12 @@ function * updateJsSnapshot (repo, version, commit) { if (hasBuiltJs !== version) { yield repoutil.forEachRepo([cordovaJsRepo], function * () { yield gitutil.stashAndPop(cordovaJsRepo, function * () { - // git fetch and update master for cordovajs - yield repoupdate.updateRepos([cordovaJsRepo], ['master'], false); - yield gitutil.gitCheckout('master'); + // git fetch and update master (or fetch other branch) for cordova-js + if (branch === 'master') { + yield repoupdate.updateRepos([cordovaJsRepo], [branch], false); + } + yield executil.execHelper(executil.ARGS('git checkout -q ' + branch)); + yield gitutil.gitCheckout(branch); yield executil.execHelper(executil.ARGS('npm install'), false, true); // WORKAROUND PART 1 for local grunt issue in cordova-js yield executil.execHelper(executil.ARGS('grunt compile:' + repo.id + ' --platformVersion=' + version), false, true); shelljs.rm('-fr', 'node_modules'); // WORKAROUND PART 2 for local grunt issue in cordova-js @@ -177,13 +180,16 @@ exports.createAndCopyCordovaJSCommand = function * () { ' 1. Generates a new cordova.js.\n' + ' 2. Replaces platform\'s cordova.js file.\n' + '\n' + - 'Usage: $0 copy-js -r platform') + 'Usage: $0 copy-js -r platform [--js ]') ); var repos = flagutil.computeReposFromFlag(argv.r); + + var jsBranchName = argv.js ? argv.js : 'master'; + yield repoutil.forEachRepo(repos, function * (repo) { var version = yield handleVersion(repo, argv.version, false); - yield updateJsSnapshot(repo, version, false); + yield updateJsSnapshot(repo, version, false, jsBranchName); }); }; @@ -199,46 +205,50 @@ exports.prepareReleaseBranchCommand = function * () { 'Command can also be used to update the JS snapshot after release \n' + 'branches have been created.\n' + '\n' + - 'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0]') + 'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0] [-b ] [--js ]') ); var repos = flagutil.computeReposFromFlag(argv.r); + + // XXX TBD ???: var branchName = null; + var isOtherRepoBranch = !!argv.b; + var repoBranchName = isOtherRepoBranch ? argv.b : 'master'; + var jsBranchName = argv.js ? argv.js : 'master'; + // First - perform precondition checks. yield repoupdate.updateRepos(repos, [], true); yield repoutil.forEachRepo(repos, function * (repo) { var platform = repo.id; var version = yield handleVersion(repo, argv.version, true); - var branchName = versionutil.getReleaseBranchNameFromVersion(version); + var releaseBranchName = isOtherRepoBranch ? repoBranchName : + versionutil.getReleaseBranchNameFromVersion(version); yield gitutil.stashAndPop(repo, function * () { // git fetch + update master - yield repoupdate.updateRepos([repo], ['master'], false); + yield repoupdate.updateRepos([repo], [repoBranchName], false); // Either create or pull down the branch. - if (yield gitutil.remoteBranchExists(repo, branchName)) { + if (yield gitutil.remoteBranchExists(repo, releaseBranchName)) { print('Remote branch already exists for repo: ' + repo.repoName); // Check out and rebase. - yield repoupdate.updateRepos([repo], [branchName], true); - yield gitutil.gitCheckout(branchName); - } else if (yield gitutil.localBranchExists(branchName)) { - yield executil.execHelper(executil.ARGS('git checkout ' + branchName)); + yield repoupdate.updateRepos([repo], [releaseBranchName], true); + yield gitutil.gitCheckout(releaseBranchName); + } else if (yield gitutil.localBranchExists(releaseBranchName)) { + yield executil.execHelper(executil.ARGS('git checkout ' + releaseBranchName)); + } else if (isOtherRepoBranch) { + yield executil.execHelper(executil.ARGS('git checkout ' + repoBranchName)); } else { yield gitutil.gitCheckout('master'); - yield executil.execHelper(executil.ARGS('git checkout -b ' + branchName)); + yield executil.execHelper(executil.ARGS('git checkout -b ' + releaseBranchName)); } - print(repo.repoName + ': Update JS snapshot version for VERSION "' + version + '" on branch "' + branchName + '".'); - yield updateJsSnapshot(repo, version, true); + yield updateJsSnapshot(repo, version, true, jsBranchName); - print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + branchName + '".'); - yield versionutil.updateRepoVersion(repo, version); - - if (platform === 'ios') { + if (platform === 'ios' && /\d$/.test(version)) { // Updates version in CDVAvailability.h file - print(repo.repoName + ': Update CDVAvailability.h for VERSION to "' + version + '" on branch "' + branchName + '".'); yield updateCDVAvailabilityFile(version); // Git commit changes if (yield gitutil.pendingChangesExist()) { @@ -246,15 +256,23 @@ exports.prepareReleaseBranchCommand = function * () { } } + print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".'); + yield versionutil.updateRepoVersion(repo, version); + + // skip remaining steps for this repo if other repo branch was specified: + if (isOtherRepoBranch) return; + yield gitutil.gitCheckout('master'); var devVersion = createPlatformDevVersion(version); print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".'); yield versionutil.updateRepoVersion(repo, devVersion); - yield updateJsSnapshot(repo, devVersion, true); - yield gitutil.gitCheckout(branchName); + yield updateJsSnapshot(repo, devVersion, true, jsBranchName); + yield gitutil.gitCheckout(releaseBranchName); }); }); - executil.reportGitPushResult(repos, ['master', branchName]); + + // XXX TBD ???: + executil.reportGitPushResult(repos, [repoBranchName, branchName]); }; function * tagJs (repo, version, pretend) { From 57d32c32c905b6ce0ef084a22f558e24798ae104 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Mon, 23 Jul 2018 16:44:21 -0400 Subject: [PATCH 06/20] add --tag-only option to tag-release command and fix tag-release usage --- src/platform-release.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 39df2318c..13f794776 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -275,11 +275,13 @@ exports.prepareReleaseBranchCommand = function * () { executil.reportGitPushResult(repos, [repoBranchName, branchName]); }; -function * tagJs (repo, version, pretend) { +function * tagJs (repo, version, pretend, tagOnly) { function * execOrPretend (cmd) { if (pretend) { print('PRETENDING TO RUN: ' + cmd.join(' ')); + } else if (tagOnly && cmd[1] === 'push') { + print('SKIP: ' + cmd.join(' ')); } else { yield executil.execHelper(cmd); } @@ -306,16 +308,21 @@ exports.tagReleaseBranchCommand = function * (argv) { var argv = configureReleaseCommandFlags(optimist // eslint-disable-line .usage('Tags a release branches.\n' + '\n' + - 'Usage: $0 tag-release --version=2.8.0-rc1 -r platform') + 'Usage: $0 tag-release --version=2.8.0-rc1 -r platform [--pretend] [--tag-only]') .options('pretend', { desc: 'Don\'t actually run git commands, just print out what would be run.', type: 'boolean' }) + .options('tag-only', { + desc: 'Don\'t actually push to origin, just print out what would be pushed.', + type: 'boolean' + }) ); var repos = flagutil.computeReposFromFlag(argv.r); var version = flagutil.validateVersionString(argv.version); var pretend = argv.pretend; var branchName = versionutil.getReleaseBranchNameFromVersion(version); + var tagOnly = argv['tag-only']; // First - perform precondition checks. yield repoupdate.updateRepos(repos, [], true); @@ -323,6 +330,8 @@ exports.tagReleaseBranchCommand = function * (argv) { function * execOrPretend (cmd) { if (pretend) { print('PRETENDING TO RUN: ' + cmd.join(' ')); + } else if (tagOnly && cmd[1] === 'push') { + print('SKIP: ' + cmd.join(' ')); } else { yield executil.execHelper(cmd); } @@ -354,7 +363,7 @@ exports.tagReleaseBranchCommand = function * (argv) { } else { print('Repo ' + repo.repoName + ' is already tagged.'); } - yield tagJs(repo, version, pretend); + yield tagJs(repo, version, pretend, tagOnly); }); }); From fcf0195f0d11c3c1cdb8fceac9d6b2f663c5207f Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 6 Jul 2018 16:53:06 -0400 Subject: [PATCH 07/20] EXTRA GIT WORKAROUND for package.json needed for cordova-osx (4.0.2-dev) & cordova-windows FUTURE TBD can we think of a better fix? --- src/gitutil.js | 4 ++++ src/platform-release.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/gitutil.js b/src/gitutil.js index fe7c55821..973ec75fb 100644 --- a/src/gitutil.js +++ b/src/gitutil.js @@ -137,6 +137,10 @@ exports.pendingChangesExist = function * () { exports.gitCheckout = function * (branchName) { var curBranch = yield gitutil.retrieveCurrentBranchName(true); if (curBranch !== branchName) { + // EXTRA WORKAROUND SOLUTION for package.json, + // as needed for cordova-osx & Windows + // FUTURE TBD better solution for package.json? + yield executil.execHelper(executil.ARGS('git checkout -- package.json')); return yield executil.execHelper(executil.ARGS('git checkout -q ', branchName)); } }; diff --git a/src/platform-release.js b/src/platform-release.js index 13f794776..a7b59c20a 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -143,6 +143,10 @@ function * updateJsSnapshot (repo, version, commit, branch) { if (branch === 'master') { yield repoupdate.updateRepos([cordovaJsRepo], [branch], false); } + // EXTRA WORKAROUND SOLUTION for package.json, + // as needed for cordova-osx & Windows + // FUTURE TBD better solution for package.json? + yield executil.execHelper(executil.ARGS('git checkout -- package.json')); yield executil.execHelper(executil.ARGS('git checkout -q ' + branch)); yield gitutil.gitCheckout(branch); yield executil.execHelper(executil.ARGS('npm install'), false, true); // WORKAROUND PART 1 for local grunt issue in cordova-js From 4f4296622a65d40297966f4329e5108f80e82b55 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 27 Jul 2018 16:17:28 -0400 Subject: [PATCH 08/20] Show if version was updated in package.json --- src/versionutil.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/versionutil.js b/src/versionutil.js index 7c1909939..afd55fd55 100644 --- a/src/versionutil.js +++ b/src/versionutil.js @@ -130,6 +130,7 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { // Update the package.json VERSION. var packageFilePaths = repo.packageFilePaths || ['package.json']; + var pendingChangesExistInJSON = false; if (fs.existsSync(packageFilePaths[0])) { fs.readFile(packageFilePaths[0], {encoding: 'utf-8'}, function (err, data) { if (err) throw err; @@ -138,7 +139,8 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { // use 2 spaces indent similar to npm fs.writeFileSync(packageFilePaths[0], JSON.stringify(packageJSON, null, 2) + '\n'); }); - if (!(yield gitutil.pendingChangesExist())) { + pendingChangesExistInJSON = yield gitutil.pendingChangesExist(); + if (!pendingChangesExistInJSON) { apputil.print('package.json file was already up-to-date.'); } } else { @@ -170,6 +172,8 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { var commitChanges = !!(opts ? opts.commitChanges : true); if (commitChanges && (yield gitutil.pendingChangesExist())) { - yield gitutil.commitChanges('Set VERSION to ' + version + ' (via coho)'); + var versionDescription = pendingChangesExistInJSON ? + 'version & VERSION' : 'VERSION'; + yield gitutil.commitChanges('Set ' + versionDescription + ' to ' + version + ' (via coho)'); } }; From dfc4ec086b03b62d9aa9cf61075472a44e7752df Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Fri, 27 Jul 2018 18:55:56 -0400 Subject: [PATCH 09/20] platforms-release-process doc updates according to recent changes: - usage with non-master release branch - tag without automatic push --- docs/platforms-release-process.md | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/docs/platforms-release-process.md b/docs/platforms-release-process.md index 5a6e234b3..09c46e1f0 100644 --- a/docs/platforms-release-process.md +++ b/docs/platforms-release-process.md @@ -260,13 +260,19 @@ Create and prepare your release branch by using `coho prepare-platform-release-b 3. Propagates version number from `--version` argument (or from `package.json` if there is no `--version` argument) to all other files (`VERSION` and similar [e.g. `build.gradle` for Android]) on the release branch `5.0.x` 4. Prepares `master` for future development already: It gives version (`package.json`, `VERSION` and similar) a minor bump and adds `-dev` (=> `5.1.0-dev`) again -Run the following command (make sure to replace the version below with what is listed inside `package.json`). +Run the following command (make sure to replace the version below with what is listed inside `package.json`) in case of release from the `master`: - coho prepare-platform-release-branch --version 5.0.0 -r android + coho prepare-platform-release-branch --version 7.2.0 -r android + +or in case of release from another release branch: + + coho prepare-platform-release-branch --version 7.1.1 -r android -b 7.1.x Then ensure commits look okay on both branches - coho repo-status -r android -b master -b 5.0.x + coho repo-status -r android -b master -b 7.1.x + +or use git tool to verify manually. ## Testing @@ -357,25 +363,31 @@ Create a JIRA issue for it, and mark it as a blocker. All good? Have another look at the changes: - coho repo-status -r android -b master -b 5.0.x + coho repo-status -r android -b master -b 7.1.x If changes look right: coho repo-push -r android -b master -b 5.0.x -This pushes the commits in both `master` and `5.0.x` (the release branch) to the remote. +This pushes the commits in both `master` and `7.1.x` (the release branch) to the remote. ### Tag and push tag Before you tag, run this command: - coho tag-platform-release --version 5.0.0 -r android --pretend + coho tag-platform-release --version 7.1.0 -r android --pretend Seems okay? Then execute it by running: - coho tag-platform-release --version 5.0.0 -r android + coho tag-platform-release --version 7.1.0 -r android + +This command also tags `cordova-js` with `android-7.1.0` and pushes it. + +To tag without automatic push: + + coho tag-platform-release --version 7.1.0 -r android --tag-only -This command also tags `cordova-js` with `android-5.0.0` and pushes it. +and then manually push the new tags. ## Publish Release Candidate to `dist/dev` From f5b6e2cb7236c6de689d7ed1cdb58b160c8a4465 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 1 Aug 2018 19:23:54 -0400 Subject: [PATCH 10/20] skip extra -dev version if not final release --- src/platform-release.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/platform-release.js b/src/platform-release.js index a7b59c20a..6185bc846 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -266,6 +266,9 @@ exports.prepareReleaseBranchCommand = function * () { // skip remaining steps for this repo if other repo branch was specified: if (isOtherRepoBranch) return; + // or skip remaining steps if not a final release version: + if (version.indexOf('-') !== -1) return; + yield gitutil.gitCheckout('master'); var devVersion = createPlatformDevVersion(version); print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".'); From c4407945a8cc4ed4923fef2c42cded854e623816 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 1 Aug 2018 19:39:53 -0400 Subject: [PATCH 11/20] prepare-platform-release-branch commit prefix opt --- src/platform-release.js | 16 +++++++++------- src/versionutil.js | 4 +++- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 6185bc846..37a1b73ed 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -130,7 +130,7 @@ function * updateCDVAvailabilityFile (version) { fs.writeFileSync(iosFile, iosFileContents.join('\n')); } -function * updateJsSnapshot (repo, version, commit, branch) { +function * updateJsSnapshot (repo, version, commit, branch, commitPrefixOrUndefined) { function * ensureJsIsBuilt () { var cordovaJsRepo = repoutil.getRepoById('js'); if (repo.id === 'blackberry') { @@ -170,7 +170,8 @@ function * updateJsSnapshot (repo, version, commit, branch) { }); if (commit === true) { if (yield gitutil.pendingChangesExist()) { - yield executil.execHelper(executil.ARGS('git commit -am', 'Update JS snapshot to version ' + version + ' (via coho)')); + var pre = !!commitPrefixOrUndefined ? commitPrefixOrUndefined : ''; + yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Update JS snapshot to version ' + version + ' (via coho)')); } } } else if (repoutil.repoGroups.all.indexOf(repo) !== -1) { @@ -209,7 +210,7 @@ exports.prepareReleaseBranchCommand = function * () { 'Command can also be used to update the JS snapshot after release \n' + 'branches have been created.\n' + '\n' + - 'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0] [-b ] [--js ]') + 'Usage: $0 prepare-platform-release-branch -r platform [--version=3.6.0] [-b ] [--js ] [--pre ') ); var repos = flagutil.computeReposFromFlag(argv.r); @@ -220,6 +221,7 @@ exports.prepareReleaseBranchCommand = function * () { var isOtherRepoBranch = !!argv.b; var repoBranchName = isOtherRepoBranch ? argv.b : 'master'; var jsBranchName = argv.js ? argv.js : 'master'; + var pre = argv.pre ? argv.pre : ''; // First - perform precondition checks. yield repoupdate.updateRepos(repos, [], true); @@ -249,19 +251,19 @@ exports.prepareReleaseBranchCommand = function * () { yield executil.execHelper(executil.ARGS('git checkout -b ' + releaseBranchName)); } - yield updateJsSnapshot(repo, version, true, jsBranchName); + yield updateJsSnapshot(repo, version, true, jsBranchName, pre); if (platform === 'ios' && /\d$/.test(version)) { // Updates version in CDVAvailability.h file yield updateCDVAvailabilityFile(version); // Git commit changes if (yield gitutil.pendingChangesExist()) { - yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).')); + yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Add ' + version + ' to CDVAvailability.h (via coho).')); } } print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".'); - yield versionutil.updateRepoVersion(repo, version); + yield versionutil.updateRepoVersion(repo, version, {commitChanges:true, pre:pre}); // skip remaining steps for this repo if other repo branch was specified: if (isOtherRepoBranch) return; @@ -272,7 +274,7 @@ exports.prepareReleaseBranchCommand = function * () { yield gitutil.gitCheckout('master'); var devVersion = createPlatformDevVersion(version); print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".'); - yield versionutil.updateRepoVersion(repo, devVersion); + yield versionutil.updateRepoVersion(repo, devVersion, {commitChanges:true, pre:pre}); yield updateJsSnapshot(repo, devVersion, true, jsBranchName); yield gitutil.gitCheckout(releaseBranchName); }); diff --git a/src/versionutil.js b/src/versionutil.js index afd55fd55..fdd2c1d9e 100644 --- a/src/versionutil.js +++ b/src/versionutil.js @@ -86,6 +86,7 @@ exports.getReleaseBranchNameFromVersion = function (version) { * @param {Object} [opts] An options object * @param {Boolean} [opts.commitChanges=true] Specifies whether to commit changes * to the repo after update is done. + * @param {String} [opts.pre=''] Optional commit prefix */ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { // Update the VERSION files. @@ -174,6 +175,7 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { if (commitChanges && (yield gitutil.pendingChangesExist())) { var versionDescription = pendingChangesExistInJSON ? 'version & VERSION' : 'VERSION'; - yield gitutil.commitChanges('Set ' + versionDescription + ' to ' + version + ' (via coho)'); + var pre = opts.pre || ''; + yield gitutil.commitChanges(pre + 'Set ' + versionDescription + ' to ' + version + ' (via coho)'); } }; From 9d51d1a439c03d565b801afda729fa87cb658a96 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Wed, 1 Aug 2018 19:46:27 -0400 Subject: [PATCH 12/20] remove extra from commit messages needed in case of commit prefix such as --pre='CB-12345 ' --- src/platform-release.js | 2 +- src/versionutil.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 37a1b73ed..6212452c0 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -171,7 +171,7 @@ function * updateJsSnapshot (repo, version, commit, branch, commitPrefixOrUndefi if (commit === true) { if (yield gitutil.pendingChangesExist()) { var pre = !!commitPrefixOrUndefined ? commitPrefixOrUndefined : ''; - yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Update JS snapshot to version ' + version + ' (via coho)')); + yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Update JS to version ' + version + ' (via coho)')); } } } else if (repoutil.repoGroups.all.indexOf(repo) !== -1) { diff --git a/src/versionutil.js b/src/versionutil.js index fdd2c1d9e..6e4786809 100644 --- a/src/versionutil.js +++ b/src/versionutil.js @@ -176,6 +176,6 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { var versionDescription = pendingChangesExistInJSON ? 'version & VERSION' : 'VERSION'; var pre = opts.pre || ''; - yield gitutil.commitChanges(pre + 'Set ' + versionDescription + ' to ' + version + ' (via coho)'); + yield gitutil.commitChanges(pre + 'Set ' + versionDescription + ' to ' + version + ' (coho)'); } }; From 50bfbd869c648852418eebb53687c0a4528273f9 Mon Sep 17 00:00:00 2001 From: Chris Brody Date: Tue, 21 May 2019 12:45:36 -0400 Subject: [PATCH 13/20] Update docs/platforms-release-process.md as suggested by @janpio Co-Authored-By: Jan Piotrowski --- docs/platforms-release-process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms-release-process.md b/docs/platforms-release-process.md index 1e0db1ee5..09c43a92e 100644 --- a/docs/platforms-release-process.md +++ b/docs/platforms-release-process.md @@ -261,7 +261,7 @@ Then ensure commits look okay on both branches coho repo-status -r android -b master -b 7.1.x -or use git tool to verify manually. +or verify manually (e.g. by looking at the git commit messages). ## Testing From 89d80f89134707ecf14e193835469ce4632e79df Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 12:48:08 -0400 Subject: [PATCH 14/20] update comment in src/platform-release.js --- src/platform-release.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/platform-release.js b/src/platform-release.js index 0f6ab7ce9..2a02ba1fa 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -233,7 +233,8 @@ exports.prepareReleaseBranchCommand = function * () { versionutil.getReleaseBranchNameFromVersion(version); yield gitutil.stashAndPop(repo, function * () { - // git fetch + update master + // git fetch & update master + // or other branch yield repoupdate.updateRepos([repo], [repoBranchName], false); // Either create or pull down the branch. From ab591b7069db32b7f4373b737298fcf088cad38e Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 12:50:30 -0400 Subject: [PATCH 15/20] REVERT changes for iOS for now (but keep vertical spacing) - test for version with all digits before updating CDVAvailability.h - a4110226b5e5ad9f36a1782dd8ca972870c0f0cb - move the code to Prepare CDVAvailability.h - 7b54e2752305a3b833885bb94fb915b0c038a3c8. in order to avoid merge conflict with master --- src/platform-release.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 2a02ba1fa..80edfdc86 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -237,6 +237,15 @@ exports.prepareReleaseBranchCommand = function * () { // or other branch yield repoupdate.updateRepos([repo], [repoBranchName], false); + if (platform === 'ios') { + // Updates version in CDVAvailability.h file + yield updateCDVAvailabilityFile(version); + // Git commit changes + if (yield gitutil.pendingChangesExist()) { + yield executil.execHelper(executil.ARGS('git commit -am', 'Added ' + version + ' to CDVAvailability.h (via coho).')); + } + } + // Either create or pull down the branch. if (yield gitutil.remoteBranchExists(repo, releaseBranchName)) { print('Remote branch already exists for repo: ' + repo.repoName); @@ -254,15 +263,6 @@ exports.prepareReleaseBranchCommand = function * () { yield updateJsSnapshot(repo, version, true, jsBranchName, pre); - if (platform === 'ios' && /\d$/.test(version)) { - // Updates version in CDVAvailability.h file - yield updateCDVAvailabilityFile(version); - // Git commit changes - if (yield gitutil.pendingChangesExist()) { - yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Add ' + version + ' to CDVAvailability.h (via coho).')); - } - } - print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".'); yield versionutil.updateRepoVersion(repo, version, {commitChanges:true, pre:pre}); From f58af4f89458ee6b144e5fcb2fb7c70d300524ce Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 12:55:09 -0400 Subject: [PATCH 16/20] Add XXX TODO comments to src/platform-release.js (in place of XXX TBD ??? comments that were added before) --- src/platform-release.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 80edfdc86..fbc072500 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -215,7 +215,8 @@ exports.prepareReleaseBranchCommand = function * () { var repos = flagutil.computeReposFromFlag(argv.r); - // XXX TBD ???: + // XXX TODO this variable should either be updated or removed + // from this function. var branchName = null; var isOtherRepoBranch = !!argv.b; @@ -229,6 +230,8 @@ exports.prepareReleaseBranchCommand = function * () { yield repoutil.forEachRepo(repos, function * (repo) { var platform = repo.id; var version = yield handleVersion(repo, argv.version, true); + // XXX TODO this should probably be used in the + // executil.reportGitPushResult call below. var releaseBranchName = isOtherRepoBranch ? repoBranchName : versionutil.getReleaseBranchNameFromVersion(version); @@ -281,7 +284,8 @@ exports.prepareReleaseBranchCommand = function * () { }); }); - // XXX TBD ???: + // XXX TODO: show correct branch name as + // branchName is no longer updated in the code above. executil.reportGitPushResult(repos, [repoBranchName, branchName]); }; From 0916886454988220c51a6c20037ca3687e1ec322 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 12:59:47 -0400 Subject: [PATCH 17/20] XXX TODO comments for code to update CDVAvailability.h --- src/platform-release.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/platform-release.js b/src/platform-release.js index 59a912d9c..dfbeb7bca 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -246,6 +246,7 @@ exports.prepareReleaseBranchCommand = function * () { // or other branch yield repoupdate.updateRepos([repo], [repoBranchName], false); + // XXX TODO move code to update CDVAvailability.h file from here: if (platform === 'ios' || platform === 'osx') { // Updates version in CDVAvailability.h file yield updateCDVAvailabilityFile(version, platform); @@ -272,6 +273,16 @@ exports.prepareReleaseBranchCommand = function * () { yield updateJsSnapshot(repo, version, true, jsBranchName, pre); + //* XXX TODO move code to update CDVAvailability.h file to here + //* but skip this update if version is not all digits + //* to avoid a build or runtime error + //* (I forgot which one it was) + //* if ((platform === 'ios' || platform === 'osx') + //* && /\d$/.test(version)) { + //* // Updates version in CDVAvailability.h file + //* // ... + //* } + print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".'); yield versionutil.updateRepoVersion(repo, version, {commitChanges:true, pre:pre}); From 7862dabc989f99f327ec6915201a881de47dba75 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 13:16:46 -0400 Subject: [PATCH 18/20] XXX TODO comments to raise issues --- src/gitutil.js | 1 + src/platform-release.js | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/gitutil.js b/src/gitutil.js index 973ec75fb..d4051f31c 100644 --- a/src/gitutil.js +++ b/src/gitutil.js @@ -137,6 +137,7 @@ exports.pendingChangesExist = function * () { exports.gitCheckout = function * (branchName) { var curBranch = yield gitutil.retrieveCurrentBranchName(true); if (curBranch !== branchName) { + // XXX TODO raise an issue for this: // EXTRA WORKAROUND SOLUTION for package.json, // as needed for cordova-osx & Windows // FUTURE TBD better solution for package.json? diff --git a/src/platform-release.js b/src/platform-release.js index dfbeb7bca..53d221991 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -149,12 +149,14 @@ function * updateJsSnapshot (repo, version, commit, branch, commitPrefixOrUndefi if (branch === 'master') { yield repoupdate.updateRepos([cordovaJsRepo], [branch], false); } + // XXX TODO raise an issue for this: // EXTRA WORKAROUND SOLUTION for package.json, // as needed for cordova-osx & Windows // FUTURE TBD better solution for package.json? yield executil.execHelper(executil.ARGS('git checkout -- package.json')); yield executil.execHelper(executil.ARGS('git checkout -q ' + branch)); yield gitutil.gitCheckout(branch); + // XXX TODO raise issue for WORKAROUND PART 1 and WORKAROUND PART 2 yield executil.execHelper(executil.ARGS('npm install'), false, true); // WORKAROUND PART 1 for local grunt issue in cordova-js yield executil.execHelper(executil.ARGS('grunt compile:' + repo.id + ' --platformVersion=' + version), false, true); shelljs.rm('-fr', 'node_modules'); // WORKAROUND PART 2 for local grunt issue in cordova-js From 89c84f25394c60700775b5bc5e6041ee22f201d3 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 13:41:09 -0400 Subject: [PATCH 19/20] npx eslint --fix src --- src/platform-release.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/platform-release.js b/src/platform-release.js index 53d221991..8b7b810c5 100644 --- a/src/platform-release.js +++ b/src/platform-release.js @@ -178,7 +178,7 @@ function * updateJsSnapshot (repo, version, commit, branch, commitPrefixOrUndefi }); if (commit === true) { if (yield gitutil.pendingChangesExist()) { - var pre = !!commitPrefixOrUndefined ? commitPrefixOrUndefined : ''; + var pre = commitPrefixOrUndefined || ''; yield executil.execHelper(executil.ARGS('git commit -am', pre + 'Update JS to version ' + version + ' (via coho)')); } } @@ -241,7 +241,7 @@ exports.prepareReleaseBranchCommand = function * () { // XXX TODO this should probably be used in the // executil.reportGitPushResult call below. var releaseBranchName = isOtherRepoBranch ? repoBranchName : - versionutil.getReleaseBranchNameFromVersion(version); + versionutil.getReleaseBranchNameFromVersion(version); yield gitutil.stashAndPop(repo, function * () { // git fetch & update master @@ -286,7 +286,7 @@ exports.prepareReleaseBranchCommand = function * () { //* } print(repo.repoName + ': Setting VERSION to "' + version + '" on branch "' + releaseBranchName + '".'); - yield versionutil.updateRepoVersion(repo, version, {commitChanges:true, pre:pre}); + yield versionutil.updateRepoVersion(repo, version, { commitChanges: true, pre: pre }); // skip remaining steps for this repo if other repo branch was specified: if (isOtherRepoBranch) return; @@ -297,7 +297,7 @@ exports.prepareReleaseBranchCommand = function * () { yield gitutil.gitCheckout('master'); var devVersion = createPlatformDevVersion(version); print(repo.repoName + ': Setting VERSION to "' + devVersion + '" on branch "master".'); - yield versionutil.updateRepoVersion(repo, devVersion, {commitChanges:true, pre:pre}); + yield versionutil.updateRepoVersion(repo, devVersion, { commitChanges: true, pre: pre }); yield updateJsSnapshot(repo, devVersion, true, jsBranchName); yield gitutil.gitCheckout(releaseBranchName); }); From 05136c59bce60c86c141e53d86fc1d097ad7a034 Mon Sep 17 00:00:00 2001 From: "Christopher J. Brody" Date: Tue, 21 May 2019 19:02:23 -0400 Subject: [PATCH 20/20] QUICK SQUASH FIXUP for eb6e72bb - commit prefix opt in src/versionutil.js should resolve issue on Travis CI --- src/versionutil.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/versionutil.js b/src/versionutil.js index 2b2e26b5e..a0230d906 100644 --- a/src/versionutil.js +++ b/src/versionutil.js @@ -171,7 +171,7 @@ exports.updateRepoVersion = function * updateRepoVersion (repo, version, opts) { if (commitChanges && (yield gitutil.pendingChangesExist())) { var versionDescription = pendingChangesExistInJSON ? 'version & VERSION' : 'VERSION'; - var pre = opts.pre || ''; + var pre = (opts && opts.pre) ? opts.pre : ''; yield gitutil.commitChanges(pre + 'Set ' + versionDescription + ' to ' + version + ' (coho)'); } };