Skip to content

Commit

Permalink
devops: restore publishing @next version (#1540)
Browse files Browse the repository at this point in the history
This merges the `//utils/apply_next_version.js` in to
`//utils/update_version.js`.
  • Loading branch information
aslushnikov committed Mar 26, 2020
1 parent 2203e9c commit 7e75cef
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 29 deletions.
16 changes: 8 additions & 8 deletions .travis.yml
Expand Up @@ -38,12 +38,12 @@ jobs:
include:
- node_js: '12'

# before_deploy:
# - node utils/apply_next_version.js
before_deploy:
- node utils/update_version.js --next

# deploy:
# skip_cleanup: true
# provider: script
# script: utils/publish_all_packages.sh --tip-of-tree
# on:
# branch: master
deploy:
skip_cleanup: true
provider: script
script: utils/publish_all_packages.sh --tip-of-tree
on:
branch: master
12 changes: 0 additions & 12 deletions utils/apply_next_version.js

This file was deleted.

51 changes: 42 additions & 9 deletions utils/update_version.js 100644 → 100755
@@ -1,3 +1,4 @@
#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
Expand All @@ -16,17 +17,49 @@

const fs = require('fs');
const path = require('path');
let version = process.argv[2];

if (!version || !version.match(/^v\d+\.\d+\.\d+(-post)?$/)) {
console.error(`Malformed version "${version}"`);
console.error(`Correct examples:`);
console.error(` update_version.js v1.0.0`);
console.error(` update_version.js v1.0.0-post`);
const SCRIPT_NAME = path.basename(__filename);
const USAGE = `
Usage: ${SCRIPT_NAME} [--next|<version>|--help]
--next generate the @next version and put it across all packages
<version> set a new version across all packages. See examples for format
--help show this help message
Examples:
${SCRIPT_NAME} v1.0.0
${SCRIPT_NAME} v1.0.0-post
${SCRIPT_NAME} --next
`;

if (process.argv[2] === '--help' || process.argv[2] === '-h') {
console.log(USAGE);
process.exit(0);
}

if (process.argv.length !== 3) {
console.log(`ERROR: missing version argument. Use --help for details.`);
process.exit(1);
}

version = version.substring(1);
let version = process.argv[2];
if (version === '--next') {
const packageJSON = require('../package.json');
version = package.version;
const dashIndex = version.indexOf('-');
if (dashIndex === -1)
version = version.substring(0, dashIndex);
version += '-next.' + Date.now();
console.log('Setting version to ' + version);
} else {
if (!version || !version.match(/^v\d+\.\d+\.\d+(-post)?$/)) {
console.error(`Malformed version "${version}". Use --help for details.`);
process.exit(1);
}
version = version.substring(1);
}


updatePackage(path.join(__dirname, '..', 'package.json'), packageJSON => {
packageJSON.version = version;
});
Expand All @@ -40,7 +73,7 @@ for (const packageName of ['playwright-chromium', 'playwright-firefox', 'playwri

function updatePackage(packageJSONPath, transform) {
console.log(`Updating ${packageJSONPath} to ${version}.`);
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf8'));
transform(packageJSON);
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, undefined, 2) + '\n');
}
}

0 comments on commit 7e75cef

Please sign in to comment.