-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f75c12e
commit c6939bb
Showing
6 changed files
with
237 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_ROOT="$DIRNAME/../../.." | ||
cd $LH_ROOT | ||
|
||
set -euxo pipefail | ||
|
||
# Setup a pristine git environment | ||
cd ../lighthouse-pristine | ||
|
||
if [[ -z "$(git status --porcelain)" ]]; then | ||
echo "Pristine repo already clean!" | ||
exit 0 | ||
fi | ||
|
||
git clean -fx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env bash | ||
|
||
TXT_BOLD=$(tput bold) | ||
TXT_DIM=$(tput setaf 245) | ||
TXT_RESET=$(tput sgr0) | ||
|
||
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_ROOT="$DIRNAME/../../.." | ||
cd "$LH_ROOT" | ||
|
||
set -euxo pipefail | ||
|
||
if [[ "$#" -ne 1 ]]; then | ||
echo "You must specify the version to prepare a commit for!" | ||
exit 1 | ||
fi | ||
|
||
OLD_VERSION=$(node -e "console.log(require('./package.json').version)") | ||
NEW_VERSION=$1 | ||
BRANCH_NAME="bump_$NEW_VERSION" | ||
SEMVER_PATTERN="[0-9]*\.[0-9]*\.[0-9]*" | ||
|
||
if [[ $(echo "$NEW_VERSION" | sed 's/[0-9]*\.[0-9]*\.[0-9]*/SECRET_REPLACE/g') != "SECRET_REPLACE" ]]; then | ||
echo "Incorrect version format. Must be x.x.x" | ||
exit 1 | ||
fi | ||
|
||
if [[ -n "$(git status --porcelain)" ]]; then | ||
echo "Repo has changes to the files! Commit or stash the changes to continue." | ||
exit 1 | ||
fi | ||
|
||
# Checkout a new branch for the version commit | ||
git fetch origin master | ||
git checkout origin/master | ||
git log -n 1 | ||
git branch -D "$BRANCH_NAME" || true | ||
git checkout -b "$BRANCH_NAME" | ||
|
||
# Install the dependencies. | ||
yarn install | ||
|
||
# Bump the version in package.json and clients/extension/manifest.json | ||
NEEDLE="^ \"version\": \"$SEMVER_PATTERN\"" | ||
REPLACEMENT=" \"version\": \"$NEW_VERSION\"" | ||
|
||
sed -i '' "s/$NEEDLE/$REPLACEMENT/g" package.json clients/extension/manifest.json | ||
|
||
# Update the fixtures with the new version | ||
yarn update:sample-json | ||
|
||
# Create the changelog entry | ||
yarn changelog | ||
|
||
# Add new contributors to changelog | ||
git --no-pager shortlog -s -e -n "v2.3.0..v${OLD_VERSION}" | cut -f 2 | sort > auto_contribs_prior_to_last | ||
git --no-pager shortlog -s -e -n "v${OLD_VERSION}..HEAD" | cut -f 2 | sort > auto_contribs_since_last | ||
NEW_CONTRIBUTORS=$(comm -13 auto_contribs_prior_to_last auto_contribs_since_last) | ||
rm auto_contribs_prior_to_last auto_contribs_since_last | ||
|
||
if [[ $(echo "$NEW_CONTRIBUTORS" | wc -l) -gt 1 ]]; then | ||
printf "Thanks to our new contributors 👽🐷🐰🐯🐻! \n$NEW_CONTRIBUTORS\n" | cat - changelog.md > tmp-changelog | ||
mv tmp-changelog changelog.md | ||
fi | ||
|
||
git add changelog.md lighthouse-core/test/results/ proto/ | ||
git commit -m "$NEW_VERSION" | ||
|
||
echo "Version bump commit ready on the ${TXT_BOLD}$BRANCH_NAME${TXT_RESET} branch!" | ||
|
||
echo "${TXT_DIM}Press any key to see the git diff, CTRL+C to exit...${TXT_RESET}" | ||
read -n 1 -r unused_variable | ||
git --no-pager diff HEAD^ | ||
echo "${TXT_DIM}Press any key to push to GitHub, CTRL+C to exit...${TXT_RESET}" | ||
read -n 1 -r unused_variable | ||
git push -u origin "$BRANCH_NAME" |
39 changes: 39 additions & 0 deletions
39
lighthouse-core/scripts/release/publish-prepare-package.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_PRISTINE_ROOT="$DIRNAME/../../../../lighthouse-pristine" | ||
|
||
set -euxo pipefail | ||
|
||
bash "$DIRNAME/release-prepare-pristine.sh" | ||
|
||
cd "$LH_PRISTINE_ROOT" | ||
|
||
VERSION=$(node -e "console.log(require('./package.json').version)") | ||
|
||
if ! git rev-parse "v$VERSION" ; then | ||
if ! git --no-pager log -n 1 --oneline | grep "v$VERSION" ; then | ||
echo "Cannot tag a commit other than the version bump!"; | ||
exit 1; | ||
fi | ||
|
||
git tag -a "v$VERSION" -m "v$VERSION" | ||
fi | ||
|
||
git checkout -f "v$VERSION" | ||
|
||
# Install the dependencies. | ||
yarn install | ||
|
||
# Build everything | ||
yarn build-all | ||
|
||
# Package the extension | ||
node build/build-extension.js package | ||
|
||
# Verify the npm package won't include unncessary files | ||
npm pack --dry-run | ||
npx pkgfiles | ||
|
||
echo "Make sure the files above look good!" | ||
|
27 changes: 27 additions & 0 deletions
27
lighthouse-core/scripts/release/publish-prepare-pristine.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_ROOT="$DIRNAME/../../.." | ||
cd $LH_ROOT | ||
|
||
set -euxo pipefail | ||
|
||
# Setup a pristine git environment | ||
cd ../ | ||
|
||
if [[ ! -e lighthouse-pristine/ ]]; then | ||
git clone git@github.com:GoogleChrome/lighthouse.git lighthouse-pristine | ||
fi | ||
|
||
cd lighthouse-pristine/ | ||
|
||
if [[ -n "$(git status --porcelain)" ]]; then | ||
echo "Pristine repo has changes to the files! Commit or stash the changes to continue." | ||
exit 1 | ||
fi | ||
|
||
git fetch origin | ||
git fetch --tags | ||
git checkout -f master | ||
git reset --hard origin/master | ||
git clean -fdx # Forcibly clean all untracked files and directories, including `.gitignore`d ones. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
|
||
TXT_BOLD=$(tput bold) | ||
TXT_DIM=$(tput setaf 245) | ||
TXT_RESET=$(tput sgr0) | ||
|
||
DIRNAME="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
LH_PRISTINE_ROOT="$DIRNAME/../../../../lighthouse-pristine" | ||
|
||
set -euxo pipefail | ||
|
||
bash "$DIRNAME/release-prepare-pristine.sh" | ||
|
||
cd "$LH_PRISTINE_ROOT" | ||
|
||
# Install deps | ||
yarn --check-files | ||
|
||
# Test err'thing | ||
echo "${TXT_BOLD}Building all the clients..." | ||
yarn build-all | ||
|
||
echo "Running the standard test suite..." | ||
yarn test | ||
|
||
echo "Running the smoke tests...." | ||
yarn smoke | ||
|
||
echo "Testing the CLI..." | ||
yarn start "https://example.com" --view | ||
|
||
echo "Testing a fresh local install..." | ||
VERSION=$(node -e "console.log(require('./package.json').version)") | ||
npm pack | ||
|
||
rm -rf /tmp/lighthouse-local-test || true | ||
mkdir -p /tmp/lighthouse-local-test | ||
cd /tmp/lighthouse-local-test | ||
|
||
npm init -y | ||
npm install "$LH_PRISTINE_ROOT/lighthouse-$VERSION.tgz" | ||
npm explore lighthouse -- npm run smoke | ||
npm explore lighthouse -- npm run chrome # try the manual launcher | ||
npm explore lighthouse -- npm run fast -- http://example.com | ||
|
||
cd "$LH_PRISTINE_ROOT" | ||
rm -rf /tmp/lighthouse-local-test | ||
rm "lighthouse-$VERSION.tgz" | ||
|
||
echo "${TXT_BOLD}Now manually...${TXT_RESET}" | ||
echo "✅ Test the extension. Open chrome://extensions" | ||
echo "${TXT_DIM}Press any key to continue...${TXT_RESET}" | ||
read -n 1 -r unused_variable | ||
|
||
|
||
echo "✅ Test the viewer. Open http://localhost:8000" | ||
echo " - Works with v4 report? https://gist.github.com/patrickhulce/7251f9eba409f385e4c0424515fe8009" | ||
echo "${TXT_DIM}Press any key to complete the test script...${TXT_RESET}" | ||
read -n 1 -r unused_variable |