Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc: bump-versions.js release script #9998

Merged
merged 6 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/recipes/custom-audit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"private": true,
"scripts": {},
"devDependencies": {
"lighthouse": "^3.x"
"lighthouse": "^5.6.0"
}
}
2 changes: 1 addition & 1 deletion docs/recipes/gulp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"devDependencies": {
"gulp": "^3.9.1",
"gulp-connect": "^5.0.0",
"lighthouse": "^2.x"
"lighthouse": "^5.6.0"
}
}
33 changes: 33 additions & 0 deletions lighthouse-core/scripts/release/bump-versions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @license Copyright 2019 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
'use strict';

const fs = require('fs');
const path = require('path');
const glob = require('glob');

const NEW_VERSION = process.argv[2];
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
if (!/^\d+\.\d+\.\d+$/.test(NEW_VERSION)) throw new Error('Usage: node bump-versions.json x.x.x');
const ignore = [
'**/node_modules/**',
'docs/recipes/auth/package.json',
'changelog.md',
];

for (const file of glob.sync('**/{package.json,*.md}', {ignore})) {
let text;
if (file === 'package.json') {
const pkg = require(path.resolve(file));
pkg.version = NEW_VERSION;
text = JSON.stringify(pkg, null, 2) + '\n';
} else {
// Replace `package.json`-like examples in markdown files.
text = fs.readFileSync(file, 'utf-8');
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
text = text.replace(/"lighthouse": ".*?"/g, `"lighthouse": "^${NEW_VERSION}"`);
}

fs.writeFileSync(file, text);
}
7 changes: 2 additions & 5 deletions lighthouse-core/scripts/release/prepare-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,8 @@ git checkout -b "$BRANCH_NAME"
# Install the dependencies.
yarn install

# Bump the version in package.json
NEEDLE="^ \"version\": \"$SEMVER_PATTERN\""
REPLACEMENT=" \"version\": \"$NEW_VERSION\""

sed -i '' "s/$NEEDLE/$REPLACEMENT/g" package.json
# Bump the version in package.json and others.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and the release script rewrite has begun >:)

node lighthouse-core/scripts/release/bump-versions.js $NEW_VERSION

# Update the fixtures with the new version
yarn update:sample-json
Expand Down