Skip to content

Commit 194d23a

Browse files
MrtenzPatrykLucka
authored andcommitted
Add script to update Chrome version (#2986)
I've created a script to simplify bumping Chrome and `chromedriver` a little bit. With the script you can just run `yarn update-chrome`, which fetches the latest version of `chromedriver`, and updates the version and shasum in the `install-chrome` script. Ideally we can run this automatically on Dependabot PRs, but Dependabot seems to be broken right now.
1 parent 3a19694 commit 194d23a

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"test:clean": "yarn workspaces foreach --all --parallel --verbose run test:clean",
3838
"test:verbose": "yarn workspaces foreach --all --parallel --verbose run test:verbose",
3939
"test:watch": "yarn workspaces foreach --all --parallel --verbose run test:watch",
40+
"update-chrome": "./scripts/update-chrome.sh",
4041
"update-readme-content": "tsx ./scripts/update-readme-content.mts"
4142
},
4243
"simple-git-hooks": {

scripts/install-chrome.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
set -u
55
set -o pipefail
66

7-
# To get the latest version, see <https://www.ubuntuupdates.org/ppa/google_chrome?dist=stable>
7+
# To get the latest version, run `yarn update-chrome`
88
CHROME_VERSION='131.0.6778.264-1'
99
CHROME_BINARY="google-chrome-stable_${CHROME_VERSION}_amd64.deb"
1010
CHROME_BINARY_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/${CHROME_BINARY}"

scripts/update-chrome.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
set -u
5+
set -o pipefail
6+
7+
#!/bin/bash
8+
9+
yarn add -D chromedriver
10+
11+
CHROME_VERSION=$(curl -s https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages.gz | \
12+
gunzip -c | \
13+
grep -A 1 "Package: google-chrome-stable" | grep "Version:" | awk '{print $2}')
14+
15+
if [ -z "$CHROME_VERSION" ]; then
16+
echo "Failed to fetch the version of google-chrome-stable."
17+
exit 1
18+
fi
19+
20+
CHROME_BINARY="google-chrome-stable_${CHROME_VERSION}_amd64.deb"
21+
CHROME_BINARY_URL="https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/${CHROME_BINARY}"
22+
SCRIPT_PATH="./scripts/install-chrome.sh"
23+
24+
wget -O "${CHROME_BINARY}" -t 5 "${CHROME_BINARY_URL}"
25+
CHROME_BINARY_SHA512SUM=$(shasum -a 512 "${CHROME_BINARY}" | awk '{print $1}')
26+
27+
sed -i '' "s/^CHROME_VERSION='.*'/CHROME_VERSION='${CHROME_VERSION}'/" "${SCRIPT_PATH}"
28+
sed -i '' "s/^CHROME_BINARY_SHA512SUM='.*'/CHROME_BINARY_SHA512SUM='${CHROME_BINARY_SHA512SUM}'/" "${SCRIPT_PATH}"
29+
30+
rm -rf "${CHROME_BINARY}"

0 commit comments

Comments
 (0)