SchildiChat-android/tools/install/installFromBuildkite.sh
Benoit Marty 9ca7415f5a Remove usage of Buildkite.
Build number is just removed.
Related script will need to be updated separately.
2022-11-24 14:49:55 +01:00

82 lines
2.2 KiB
Bash
Executable file

#!/usr/bin/env bash
# Exit on any error
set -e
echo "Sorry, this script needs to be updated to download APKs from GitHub action. Buildkite is not building APKs anymore."
exit 1
if [[ "$#" -ne 1 ]]; then
echo "Usage: $0 BUILDKITE_TOKEN" >&2
exit 1
fi
buildkiteToken=$1
# Path where the app is cloned (it's where this project has been cloned)
appPath=$(dirname $(dirname $(dirname $0)))
# Path where the APK will be downloaded from Buildkite (it's a dir)
baseImportPath="${appPath}/tmp/DebugApks"
# Select device
serialNumber=$(${appPath}/tools/install/androidSelectDevice.sh)
# Detect device architecture
arch=$(adb -s ${serialNumber} shell getprop ro.product.cpu.abi)
# FDroid or Gplay ?
echo
read -p "fdroid or gplay (default to gplay)? " fdroidOrGplay
fdroidOrGplay=${fdroidOrGplay:-gplay}
echo
echo "Will install ${fdroidOrGplay} version on device ${serialNumber} with arch ${arch}"
# Buildkite build number
echo
read -p "Buildkite build number (ex: '1792')? " buildkiteBuildNumber
# Download files
targetPath=${baseImportPath}/${buildkiteBuildNumber}
filename="vector-${fdroidOrGplay}-${arch}-debug.apk"
fullApkPath="${targetPath}/${filename}"
# Check if file already exists
if test -f "$fullApkPath"; then
read -p "$fullApkPath already exists. Override (yes/no) default to no ? " download
download=${download:-no}
else
download="yes"
fi
# Ignore error from now
set +e
if [ ${download} == "yes" ]; then
echo "Downloading ${filename}..."
python3 ${appPath}/tools/release/download_buildkite_artifacts.py \
--token ${buildkiteToken} \
--build ${buildkiteBuildNumber} \
--directory ${targetPath} \
--filename ${filename} \
--ignoreErrors
fi
echo "Installing ${filename} to device ${serialNumber}..."
adb -s ${serialNumber} install -r ${fullApkPath}
# Check error and propose to uninstall and retry installing
if [[ "$?" -ne 0 ]]; then
read -p "Error, do you want to uninstall the application then retry (yes/no) default to no ? " retry
retry=${retry:-no}
if [ ${retry} == "yes" ]; then
echo "Uninstalling..."
adb -s ${serialNumber} uninstall im.vector.app.debug
echo "Installing again..."
adb -s ${serialNumber} install -r ${fullApkPath}
fi
fi