Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

devops: restore publishing @next version (#1540)

Andrey Lushnikov7e75cefd2065
diff --git a/.travis.yml b/.travis.yml
index 13aa3593e4..8fab586beb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -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
diff --git a/utils/apply_next_version.js b/utils/apply_next_version.js
deleted file mode 100644
index c419b6e3f9..0000000000
--- a/utils/apply_next_version.js
+++ /dev/null
@@ -1,12 +0,0 @@
-const {execSync} = require('child_process');
-
-const package = require('../package.json');
-let 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);
-
-execSync(`npm --no-git-tag-version version ${version}`);
-
diff --git a/utils/update_version.js b/utils/update_version.js
old mode 100644
new mode 100755
index d7c6b22125..7e009251da
--- a/utils/update_version.js
+++ b/utils/update_version.js
@@ -1,3 +1,4 @@
+#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
@@ -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;
});
@@ -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');
-}
\ No newline at end of file
+}