#!/usr/bin/env php sha1sum.txt'); chdir('..'); // show the build URL in the log echo "Published here:\n"; echo "$BUILD_URL\n"; $apix = '`'; // Escaping texts for Telegram $BUILD_URL_ESCAPED = escapeshellarg($BUILD_URL); $APK_NAME_ESCAPED = escapeshellarg($APK_NAME); // add a comment to the build URL if (!empty($document_id) && empty(getenv('NO_COMMENT'))) { // We have a Differentials revision under review! $document_id_escaped = escapeshellarg($document_id); // Send message to Telegram groups. $telegram_chat_content = implode("\n", [ "⚙ Dear Android hackers, please review this promising patch:", "https://gitpull.it/$document_id_escaped", "", "Here the related fresh test build:", "[Download $APK_NAME_ESCAPED]($BUILD_URL_ESCAPED)", "", "APK sha256:", "$apix$APK_SHA256$apix" ]); echo "DEBUG TELEGRAM CONTENT\n"; echo "$telegram_chat_content\n"; shell_exec(sprintf( "~/bin/telegram-comment.sh %s %s %s || true", escapeshellarg($TELEGRAM_BOT_TOKEN), escapeshellarg($TELEGRAM_CHAT_ID), escapeshellarg($telegram_chat_content) )); // Send message to Phorge. echo "Adding bipbop Comment to $document_id\n"; shell_exec(sprintf( "~/bin/phab-comment.php %s %s %s || true", escapeshellarg($document_id), escapeshellarg($BUILD_URL), escapeshellarg($APK_SHA256) )); } else { // We have NOT a Differentials revision under review! // So this is an atomic commit. $git_commit_title_escaped = escapeshellarg($git_commit_title); $telegram_chat_content = implode("\n", [ "🌚 New commit: *$git_commit_title_escaped*", "https://gitpull.it/R4:$git_commit", "", "Try this fresh test APK:", "[Download $APK_NAME_ESCAPED]($BUILD_URL_ESCAPED)", "", "APK fingerprint sha256:", "$apix$APK_SHA256$apix" ]); echo "DEBUG TELEGRAM CONTENT\n"; echo "$telegram_chat_content\n"; shell_exec(sprintf( "~/bin/telegram-comment.sh %s %s %s || true", escapeshellarg($TELEGRAM_BOT_TOKEN), escapeshellarg($TELEGRAM_CHAT_ID), escapeshellarg($telegram_chat_content) )); } // delete very old files echo "Cleaning\n"; shell_exec(sprintf( "find %s -type f -mtime +120 -delete", escapeshellarg($BUILD_DIR) )); // clean old APK in the repository to never re-use it by mistake // as it happened when we moved everything to the /app directory unlink($APK_PATH); echo "Done\n";