mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
devops: restore publishing @next version (#1540)
This merges the `//utils/apply_next_version.js` in to `//utils/update_version.js`.
This commit is contained in:
parent
2203e9c017
commit
7e75cefd20
16
.travis.yml
16
.travis.yml
@ -38,12 +38,12 @@ jobs:
|
|||||||
include:
|
include:
|
||||||
- node_js: '12'
|
- node_js: '12'
|
||||||
|
|
||||||
# before_deploy:
|
before_deploy:
|
||||||
# - node utils/apply_next_version.js
|
- node utils/update_version.js --next
|
||||||
|
|
||||||
# deploy:
|
deploy:
|
||||||
# skip_cleanup: true
|
skip_cleanup: true
|
||||||
# provider: script
|
provider: script
|
||||||
# script: utils/publish_all_packages.sh --tip-of-tree
|
script: utils/publish_all_packages.sh --tip-of-tree
|
||||||
# on:
|
on:
|
||||||
# branch: master
|
branch: master
|
||||||
|
|||||||
@ -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}`);
|
|
||||||
|
|
||||||
51
utils/update_version.js
Normal file → Executable file
51
utils/update_version.js
Normal file → Executable file
@ -1,3 +1,4 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
/**
|
/**
|
||||||
* Copyright (c) Microsoft Corporation.
|
* Copyright (c) Microsoft Corporation.
|
||||||
*
|
*
|
||||||
@ -16,17 +17,49 @@
|
|||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
let version = process.argv[2];
|
|
||||||
|
|
||||||
if (!version || !version.match(/^v\d+\.\d+\.\d+(-post)?$/)) {
|
const SCRIPT_NAME = path.basename(__filename);
|
||||||
console.error(`Malformed version "${version}"`);
|
const USAGE = `
|
||||||
console.error(`Correct examples:`);
|
Usage: ${SCRIPT_NAME} [--next|<version>|--help]
|
||||||
console.error(` update_version.js v1.0.0`);
|
|
||||||
console.error(` update_version.js v1.0.0-post`);
|
--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);
|
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 => {
|
updatePackage(path.join(__dirname, '..', 'package.json'), packageJSON => {
|
||||||
packageJSON.version = version;
|
packageJSON.version = version;
|
||||||
});
|
});
|
||||||
@ -40,7 +73,7 @@ for (const packageName of ['playwright-chromium', 'playwright-firefox', 'playwri
|
|||||||
|
|
||||||
function updatePackage(packageJSONPath, transform) {
|
function updatePackage(packageJSONPath, transform) {
|
||||||
console.log(`Updating ${packageJSONPath} to ${version}.`);
|
console.log(`Updating ${packageJSONPath} to ${version}.`);
|
||||||
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath));
|
const packageJSON = JSON.parse(fs.readFileSync(packageJSONPath, 'utf8'));
|
||||||
transform(packageJSON);
|
transform(packageJSON);
|
||||||
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, undefined, 2) + '\n');
|
fs.writeFileSync(packageJSONPath, JSON.stringify(packageJSON, undefined, 2) + '\n');
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user