2019-11-19 05:18:28 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set +x
|
|
|
|
|
2019-11-20 03:08:27 +03:00
|
|
|
trap "cd $(pwd -P)" EXIT
|
2019-11-19 05:18:28 +03:00
|
|
|
cd "$(dirname "$0")"
|
|
|
|
|
|
|
|
if [[ ($1 == '--help') || ($1 == '-h') ]]; then
|
2019-11-23 07:49:40 +03:00
|
|
|
echo "usage: $(basename $0) [firefox|webkit] [--check] [zip-path] [--win64]"
|
2019-11-19 05:18:28 +03:00
|
|
|
echo
|
2019-11-21 05:01:07 +03:00
|
|
|
echo "Upload .zip as a browser build."
|
2019-11-19 05:18:28 +03:00
|
|
|
echo
|
2019-11-22 02:25:46 +03:00
|
|
|
echo "--check pass |--check| as a second parameter instead of a zip-path to check for"
|
|
|
|
echo " the build existing in the CDN"
|
|
|
|
echo
|
2019-11-19 05:18:28 +03:00
|
|
|
echo "NOTE: \$AZ_ACCOUNT_KEY (azure account name) and \$AZ_ACCOUNT_NAME (azure account name)"
|
|
|
|
echo "env variables are required to upload builds to CDN."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ (-z $AZ_ACCOUNT_KEY) || (-z $AZ_ACCOUNT_NAME) ]]; then
|
|
|
|
echo "ERROR: Either \$AZ_ACCOUNT_KEY or \$AZ_ACCOUNT_NAME environment variable is missing."
|
|
|
|
echo " 'Azure Account Name' and 'Azure Account Key' secrets that are required"
|
|
|
|
echo " to upload builds ot Azure CDN."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-21 05:01:07 +03:00
|
|
|
if [[ $# < 1 ]]; then
|
|
|
|
echo "missing browser: 'firefox' or 'webkit'"
|
|
|
|
echo "try '$(basename $0) --help' for more information"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-19 05:18:28 +03:00
|
|
|
BROWSER_NAME=""
|
|
|
|
BUILD_NUMBER=""
|
2019-11-21 05:01:07 +03:00
|
|
|
BLOB_NAME=""
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS=""
|
2019-11-19 05:18:28 +03:00
|
|
|
if [[ ("$1" == "firefox") || ("$1" == "firefox/") ]]; then
|
|
|
|
# we always apply our patches atop of beta since it seems to get better
|
|
|
|
# reliability guarantees.
|
|
|
|
BUILD_NUMBER=$(cat "$PWD/firefox/BUILD_NUMBER")
|
|
|
|
BROWSER_NAME="firefox"
|
2019-11-21 05:01:07 +03:00
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
|
|
BLOB_NAME="firefox-mac.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="firefox-mac r$BUILD_NUMBER"
|
2019-11-21 05:01:07 +03:00
|
|
|
elif [[ "$(uname)" == "Linux" ]]; then
|
|
|
|
BLOB_NAME="firefox-linux.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="ff-linux r$BUILD_NUMBER"
|
2019-11-23 02:44:46 +03:00
|
|
|
elif [[ "$(uname)" == MINGW* ]]; then
|
2019-11-23 07:49:40 +03:00
|
|
|
if [[ ("$2" == "--win64") || ("$3" == "--win64") ]]; then
|
|
|
|
BLOB_NAME="firefox-win64.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="ff-win64 r$BUILD_NUMBER"
|
2019-11-23 07:49:40 +03:00
|
|
|
else
|
|
|
|
BLOB_NAME="firefox-win32.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="ff-win32 r$BUILD_NUMBER"
|
2019-11-23 07:49:40 +03:00
|
|
|
fi
|
2019-11-21 05:01:07 +03:00
|
|
|
else
|
|
|
|
echo "ERROR: unzupported platform - $(uname)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-19 05:18:28 +03:00
|
|
|
elif [[ ("$1" == "webkit") || ("$1" == "webkit/") ]]; then
|
|
|
|
BUILD_NUMBER=$(cat "$PWD/webkit/BUILD_NUMBER")
|
|
|
|
BROWSER_NAME="webkit"
|
2019-11-21 05:01:07 +03:00
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
|
|
MAC_MAJOR_MINOR_VERSION=$(sw_vers -productVersion | grep -o '^\d\+.\d\+')
|
|
|
|
BLOB_NAME="minibrowser-mac-$MAC_MAJOR_MINOR_VERSION.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="webkit-mac-$MAC_MAJOR_MINOR_VERSION r$BUILD_NUMBER"
|
2019-11-21 05:01:07 +03:00
|
|
|
elif [[ "$(uname)" == "Linux" ]]; then
|
|
|
|
BLOB_NAME="minibrowser-linux.zip"
|
2019-12-11 04:43:53 +03:00
|
|
|
ALIAS="webkit-linux r$BUILD_NUMBER"
|
2019-11-21 05:01:07 +03:00
|
|
|
else
|
|
|
|
echo "ERROR: unzupported platform - $(uname)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-19 05:18:28 +03:00
|
|
|
else
|
|
|
|
echo ERROR: unknown browser to export - "$1"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-12-11 04:43:53 +03:00
|
|
|
if [[ ("$2" == '--show-alias') || ("$3" == '--show-alias') ]]; then
|
|
|
|
echo $ALIAS
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-11-22 02:25:46 +03:00
|
|
|
BLOB_PATH="$BROWSER_NAME/$BUILD_NUMBER/$BLOB_NAME"
|
2019-12-11 04:43:53 +03:00
|
|
|
if [[ ("$2" == '--check') || ("$3" == '--check') ]]; then
|
2019-11-22 02:25:46 +03:00
|
|
|
EXISTS=$(az storage blob exists -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -n "$BLOB_PATH" --query "exists")
|
|
|
|
if [[ $EXISTS == "true" ]]; then
|
|
|
|
exit 0
|
|
|
|
else
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2019-11-21 05:01:07 +03:00
|
|
|
if [[ $# < 2 ]]; then
|
|
|
|
echo "missing path to zip archive to upload"
|
|
|
|
echo "try '$(basename $0) --help' for more information"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
ZIP_PATH=$2
|
|
|
|
if ! [[ -f $ZIP_PATH ]]; then
|
|
|
|
echo "ERROR: $ZIP_PATH does not exist"
|
2019-11-19 05:18:28 +03:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-21 05:01:07 +03:00
|
|
|
if ! [[ $ZIP_PATH == *.zip ]]; then
|
|
|
|
echo "ERROR: $ZIP_PATH is not a zip archive (must have a .zip extension)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-23 04:16:47 +03:00
|
|
|
if [[ $(uname) == MINGW* ]]; then
|
2019-11-23 04:36:12 +03:00
|
|
|
# Convert POSIX path to MSYS
|
|
|
|
WIN_PATH=$({ cd $(dirname $ZIP_PATH) && pwd -W; } | sed 's|/|\\|g')
|
|
|
|
WIN_PATH="${WIN_PATH}\\$(basename $ZIP_PATH)"
|
|
|
|
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $WIN_PATH -n $BLOB_PATH
|
2019-11-23 04:16:47 +03:00
|
|
|
else
|
2019-11-23 04:36:12 +03:00
|
|
|
az storage blob upload -c builds --account-key $AZ_ACCOUNT_KEY --account-name $AZ_ACCOUNT_NAME -f $ZIP_PATH -n "$BLOB_PATH"
|
2019-11-23 04:16:47 +03:00
|
|
|
fi
|
2019-11-21 05:01:07 +03:00
|
|
|
|
|
|
|
echo "UPLOAD SUCCESSFUL!"
|
|
|
|
echo "-- SRC: $ZIP_PATH"
|
|
|
|
echo "-- SIZE: $(du -h "$ZIP_PATH" | awk '{print $1}')"
|
|
|
|
echo "-- DST: $BLOB_PATH"
|
2019-11-19 05:18:28 +03:00
|
|
|
|