2019-11-22 02:25:46 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
|
|
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
2020-01-18 01:23:31 +03:00
|
|
|
echo "usage: $(basename $0) [firefox-linux|firefox-win32|firefox-win64|webkit-gtk|webkit-win64|webkit-mac-10.14|webkit-mac-10.15] [-f|--force]"
|
2019-11-22 02:25:46 +03:00
|
|
|
echo
|
|
|
|
echo "Prepares checkout under browser folder, applies patches, builds, archives, and uploades if build is missing."
|
|
|
|
echo "Script will bail out early if the build for the browser version is already present."
|
|
|
|
echo
|
|
|
|
echo "Pass -f to upload anyway."
|
|
|
|
echo
|
|
|
|
echo "NOTE: This script is safe to run in a cronjob - it aquires a lock so that it does not run twice."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $# == 0 ]]; then
|
2020-01-18 01:23:31 +03:00
|
|
|
echo "missing build flavor!"
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "try './$(basename $0) --help' for more information"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-18 01:23:31 +03:00
|
|
|
CURRENT_HOST_OS="$(uname)"
|
|
|
|
CURRENT_HOST_OS_VERSION=""
|
|
|
|
if [[ "$CURRENT_HOST_OS" == "Darwin" ]]; then
|
|
|
|
CURRENT_HOST_OS_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
|
|
|
|
fi
|
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
BROWSER_NAME=""
|
2020-01-11 04:30:35 +03:00
|
|
|
EXTRA_BUILD_ARGS=""
|
2020-01-18 01:23:31 +03:00
|
|
|
BUILD_FLAVOR="$1"
|
|
|
|
EXPECTED_HOST_OS=""
|
|
|
|
EXPECTED_HOST_OS_VERSION=""
|
|
|
|
if [[ "$BUILD_FLAVOR" == "firefox-linux" ]]; then
|
|
|
|
BROWSER_NAME="firefox"
|
|
|
|
EXPECTED_HOST_OS="Linux"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "firefox-mac" ]]; then
|
|
|
|
BROWSER_NAME="firefox"
|
|
|
|
EXPECTED_HOST_OS="Darwin"
|
|
|
|
EXPECTED_HOST_OS_VERSION="10.14"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "firefox-win32" ]]; then
|
2019-11-22 02:25:46 +03:00
|
|
|
BROWSER_NAME="firefox"
|
2020-01-18 01:23:31 +03:00
|
|
|
EXPECTED_HOST_OS="MINGW"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "firefox-win64" ]]; then
|
2020-01-11 04:30:35 +03:00
|
|
|
BROWSER_NAME="firefox"
|
|
|
|
EXTRA_BUILD_ARGS="--win64"
|
2020-01-18 01:23:31 +03:00
|
|
|
EXPECTED_HOST_OS="MINGW"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "webkit-gtk" ]]; then
|
|
|
|
BROWSER_NAME="webkit"
|
|
|
|
EXPECTED_HOST_OS="Linux"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "webkit-win64" ]]; then
|
|
|
|
BROWSER_NAME="webkit"
|
|
|
|
EXPECTED_HOST_OS="MINGW"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "webkit-mac-10.14" ]]; then
|
|
|
|
BROWSER_NAME="webkit"
|
|
|
|
EXPECTED_HOST_OS="Darwin"
|
|
|
|
EXPECTED_HOST_OS_VERSION="10.14"
|
|
|
|
elif [[ "$BUILD_FLAVOR" == "webkit-mac-10.15" ]]; then
|
2019-11-22 02:25:46 +03:00
|
|
|
BROWSER_NAME="webkit"
|
2020-01-18 01:23:31 +03:00
|
|
|
EXPECTED_HOST_OS="Darwin"
|
|
|
|
EXPECTED_HOST_OS_VERSION="10.15"
|
2019-11-22 02:25:46 +03:00
|
|
|
else
|
2020-01-18 01:23:31 +03:00
|
|
|
echo ERROR: unknown build flavor - "$BUILD_FLAVOR"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$CURRENT_HOST_OS" != $EXPECTED_HOST_OS* ]]; then
|
|
|
|
echo "ERROR: cannot build $BUILD_FLAVOR"
|
|
|
|
echo " -- expected OS: $EXPECTED_HOST_OS"
|
|
|
|
echo " -- current OS: $CURRENT_HOST_OS"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ "$CURRENT_HOST_OS_VERSION" != "$EXPECTED_HOST_OS_VERSION" ]]; then
|
|
|
|
echo "ERROR: cannot build $BUILD_FLAVOR"
|
|
|
|
echo " -- expected OS Version: $EXPECTED_HOST_OS_VERSION"
|
|
|
|
echo " -- current OS Version: $CURRENT_HOST_OS_VERSION"
|
2019-11-22 02:25:46 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-23 04:16:47 +03:00
|
|
|
if [[ $(uname) == MINGW* ]]; then
|
|
|
|
ZIP_PATH="$PWD/archive-$BROWSER_NAME.zip"
|
|
|
|
else
|
|
|
|
ZIP_PATH="/tmp/archive-$BROWSER_NAME.zip"
|
|
|
|
fi
|
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
if [[ -f $ZIP_PATH ]]; then
|
|
|
|
echo "Archive $ZIP_PATH already exists - remove and re-run the script."
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-12-12 01:19:55 +03:00
|
|
|
trap "rm -rf ${ZIP_PATH}; cd $(pwd -P);" INT TERM EXIT
|
2019-11-22 02:25:46 +03:00
|
|
|
cd "$(dirname "$0")"
|
2019-12-11 04:43:53 +03:00
|
|
|
BUILD_NUMBER=$(cat ./$BROWSER_NAME/BUILD_NUMBER)
|
2019-11-22 02:25:46 +03:00
|
|
|
|
|
|
|
# pull from upstream and check if a new build has to be uploaded.
|
|
|
|
if ! [[ ($2 == '-f') || ($2 == '--force') ]]; then
|
2020-01-18 01:23:31 +03:00
|
|
|
if ./upload.sh $BUILD_FLAVOR --check; then
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "Build is already uploaded - no changes."
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
echo "Build is missing - rebuilding"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Force-rebuilding the build."
|
|
|
|
fi
|
|
|
|
|
2019-12-12 01:19:55 +03:00
|
|
|
cd ./$BROWSER_NAME/checkout
|
|
|
|
if ! [[ $(git rev-parse --abbrev-ref HEAD) == "playwright-build" ]]; then
|
|
|
|
echo "ERROR: Default branch is not playwright-build!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
cd -
|
|
|
|
|
2019-12-11 04:43:53 +03:00
|
|
|
source ./buildbots/send_telegram_message.sh
|
2020-01-11 02:35:30 +03:00
|
|
|
LAST_COMMIT_MESSAGE=$(git log --format=%s -n 1 HEAD -- ./$BROWSER_NAME/BUILD_NUMBER)
|
2020-01-18 01:23:31 +03:00
|
|
|
BUILD_ALIAS="<b>[[$BUILD_FLAVOR r$BUILD_NUMBER]]</b> $LAST_COMMIT_MESSAGE"
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- started ⏳"
|
2019-12-11 04:43:53 +03:00
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "-- preparing checkout"
|
2019-12-12 01:19:55 +03:00
|
|
|
if ! ./prepare_checkout.sh $BROWSER_NAME; then
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- ./prepare_checkout.sh failed! ❌"
|
2019-12-10 01:38:23 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-23 06:07:39 +03:00
|
|
|
echo "-- cleaning"
|
2019-12-12 01:19:55 +03:00
|
|
|
if ! ./$BROWSER_NAME/clean.sh; then
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- ./clean.sh failed! ❌"
|
2019-12-12 01:19:55 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-23 07:49:40 +03:00
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "-- building"
|
2020-01-11 04:30:35 +03:00
|
|
|
if ! ./$BROWSER_NAME/build.sh "$EXTRA_BUILD_ARGS"; then
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- ./build.sh failed! ❌"
|
2019-12-11 04:43:53 +03:00
|
|
|
exit 1
|
2019-11-23 07:49:40 +03:00
|
|
|
fi
|
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "-- archiving to $ZIP_PATH"
|
2019-12-12 01:19:55 +03:00
|
|
|
if ! ./$BROWSER_NAME/archive.sh $ZIP_PATH; then
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- ./archive.sh failed! ❌"
|
2019-12-12 01:19:55 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-23 07:49:40 +03:00
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "-- uploading"
|
2020-01-18 01:23:31 +03:00
|
|
|
if ! ./upload.sh $BUILD_FLAVOR $ZIP_PATH; then
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- ./upload.sh failed! ❌"
|
2019-12-12 01:19:55 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2020-01-08 18:43:57 +03:00
|
|
|
send_telegram_message "$BUILD_ALIAS -- uploaded ✅"
|