Add error message when build fails

This commit is contained in:
Sayantan Santra 2023-04-23 18:52:32 -05:00
parent 16c25d7460
commit bfb0981e05

View file

@ -150,6 +150,9 @@ fi
[[ ! -z "$excluded_patches" ]] && populate_patches "-e" "$excluded_patches" [[ ! -z "$excluded_patches" ]] && populate_patches "-e" "$excluded_patches"
[[ ! -z "$included_patches" ]] && populate_patches "-i" "$included_patches" [[ ! -z "$included_patches" ]] && populate_patches "-i" "$included_patches"
# Variable to flag errors
error=0
# Functions for building the APKs # Functions for building the APKs
build_yt_nonroot() { build_yt_nonroot() {
@ -169,7 +172,7 @@ build_yt_nonroot() {
echo "************************************" echo "************************************"
# Rename files # Rename files
mv revanced-yt-nonroot.apk YouTube_ReVanced_nonroot_$timestamp.apk mv revanced-yt-nonroot.apk YouTube_ReVanced_nonroot_$timestamp.apk || error=1
} }
build_yt_root() { build_yt_root() {
@ -189,7 +192,7 @@ build_yt_root() {
echo "************************************" echo "************************************"
# Rename files # Rename files
mv revanced-yt-root.apk YouTube_ReVanced_root_$timestamp.apk mv revanced-yt-root.apk YouTube_ReVanced_root_$timestamp.apk || error=1
} }
build_ytm_nonroot() { build_ytm_nonroot() {
@ -206,7 +209,7 @@ build_ytm_nonroot() {
fi fi
# Rename files # Rename files
mv revanced-ytm-nonroot.apk YouTube_Music_ReVanced_nonroot_$timestamp.apk mv revanced-ytm-nonroot.apk YouTube_Music_ReVanced_nonroot_$timestamp.apk || error=1
} }
build_ytm_root() { build_ytm_root() {
@ -223,7 +226,7 @@ build_ytm_root() {
fi fi
# Rename files # Rename files
mv revanced-ytm-root.apk YouTube_Music_ReVanced_root_$timestamp.apk mv revanced-ytm-root.apk YouTube_Music_ReVanced_root_$timestamp.apk || error=1
} }
# Check the config and build accordingly # Check the config and build accordingly
@ -234,6 +237,15 @@ $YTM_ROOT && build_ytm_root
# Send telegram message about the new build # Send telegram message about the new build
if [ $error == 1 ]; then
echo "There was an error while building!"
if $TG_NOTIFICATIONS; then
./telegram.sh -t "$TELEGRAM_TOKEN" -c "$TELEGRAM_CHAT" -T "❗❗❗ Build Error ❗❗❗" -M "There was an error during the build process! Please take a look at the logs."$'\n'"Timestamp: $timestamp"$'\n'"⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯"
fi
mv versions.json versions.json.bk
exit 4
fi
if $TG_UPLOAD; then if $TG_UPLOAD; then
echo "Uploading to telegram" echo "Uploading to telegram"
# telegram-upload uses personal account, hence bypassing 50 MB max upload limit of bots # telegram-upload uses personal account, hence bypassing 50 MB max upload limit of bots