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

Update replace existing chrome validation #116

Merged
merged 5 commits into from
Dec 2, 2024
Merged
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
42 changes: 33 additions & 9 deletions src/scripts/install-chrome.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,62 @@ PROCESSED_CHROME_VERSION=$(circleci env subst "$ORB_PARAM_CHROME_VERSION")
# installation check
if uname -a | grep Darwin >/dev/null 2>&1; then
if ls /Applications/*Google\ Chrome* >/dev/null 2>&1; then
if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ]; then
echo "$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version)is currently installed; replacing it"
LATEST_VERSION="$(curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Mac' | jq -r ' .[0] | .version ')"
if [[ "$PROCESSED_CHROME_VERSION" == "latest" ]]; then
target_version="$LATEST_VERSION"
else
target_version="$PROCESSED_CHROME_VERSION"
fi
installed_version="$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version)"

if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ] && [ "$installed_version" != "$target_version" ]; then
echo "$installed_version is currently installed; replacing it"
HOMEBREW_NO_AUTO_UPDATE=1 brew uninstall google-chrome >/dev/null 2>&1 || true
$SUDO rm -rf /Applications/Google\ Chrome.app >/dev/null 2>&1 || true
else
echo "$(/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --version)is already installed"
echo "$installed_version is already installed"
exit 0
fi
else
echo "Google Chrome is not currently installed; installing it"
fi
elif grep Alpine /etc/issue >/dev/null 2>&1; then
if command -v chromium-browser >/dev/null 2>&1; then
if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ]; then
echo "$(chromium-browser --version)is currently installed; replacing it"
LATEST_VERSION="$(curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Linux' | jq -r ' .[0] | .version ')"
if [[ "$PROCESSED_CHROME_VERSION" == "latest" ]]; then
target_version="$LATEST_VERSION"
else
target_version="$PROCESSED_CHROME_VERSION"
fi
installed_version="$(chromium-browser --version)"

if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ] && [ "$installed_version" != "$target_version" ]; then
echo "$installed_version is currently installed; replacing it"
$SUDO apk del --force-broken-world chromium >/dev/null 2>&1 || true
$SUDO rm -f "$(command -v chromium-browser)" >/dev/null 2>&1 || true
else
echo "$(chromium-browser --version)is already installed to $(command -v chromium-browser)"
echo "$installed_version is already installed to $(command -v chromium-browser)"
exit 0
fi
else
echo "Google Chrome (via Chromium) is not currently installed; installing it"
fi
elif command -v yum >/dev/null 2>&1; then
if command -v google-chrome >/dev/null 2>&1; then
if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ]; then
echo "$(google-chrome --version)is currently installed; replacing it"
LATEST_VERSION="$(curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Stable&platform=Linux' | jq -r ' .[0] | .version ')"
if [[ "$PROCESSED_CHROME_VERSION" == "latest" ]]; then
target_version="$LATEST_VERSION"
else
target_version="$PROCESSED_CHROME_VERSION"
fi
installed_version="$(google-chrome --version)"

if [ "$ORB_PARAM_REPLACE_EXISTING" == "1" ] && [ "$installed_version" != "$target_version" ]; then
echo "$installed_version is currently installed; replacing it"
$SUDO yum remove -y google-chrome-stable >/dev/null 2>&1 || true
$SUDO rm -f "$(command -v google-chrome)" >/dev/null 2>&1 || true
else
echo "$(google-chrome --version)is already installed to $(command -v google-chrome)"
echo "$installed_version is already installed to $(command -v google-chrome)"
exit 0
fi
else
Expand Down