Page MenuHomeGitPull.it

Libre BusTO ublish-latest-branch-build.sh
ActivePublic

Authored by valerio.bozzolan on Jun 15 2023, 15:39.
Referenced Files
F3619762: Libre BusTO ublish-latest-branch-build.sh
May 9 2025, 15:22
F1965534: Libre BusTO ublish-latest-branch-build.sh
Dec 21 2023, 07:44
F1762430: Libre BusTO ublish-latest-branch-build.sh
Jun 15 2023, 15:40
F1762429: Libre BusTO ublish-latest-branch-build.sh
Jun 15 2023, 15:39
Subscribers
None
################################################################
#
# Currently in use here:
# https://gitpull.it/harbormaster/step/view/6/
#
# Source code:
# https://gitpull.it/P23
#
# -- Valerio B., Wed 26 Feb 2020 11:54:30 PM CET
#
################################################################
#
# Usage: the first argument is the Differential ID number
# or empty if working on master.
#
# die on errors
set -e
# Require the Telegram
if [ -f ~/.phorge_bot_telegram_config ]; then
echo "[INFO] including .env file"
. ~/.phorge_bot_telegram_config
else
echo "[WARN] skipping non-existing ~/.phorge_bot_telegram_config file for user $(whoami) with home $HOME"
fi
# expected base URL
EXPECTED_DEPLOY_URL=https://lab.reyboz.it/builds/libre-busto/
# pathname to the repository built apk file
#APK_PATH=./build/outputs/apk/release/libre-busto-release-unsigned.apk
#APK_PATH=./app/build/outputs/apk/debug/libre-busto-debug.apk
#APK_PATH=./app/build/outputs/apk/debug/app-debug.apk
APK_PATH=./app/build/outputs/apk/gitpull/app-gitpull-signed.apk
# Git commit hash
git_commit=$(git rev-parse HEAD)
git_commit_title=$(git show --pretty=format:%s -s HEAD)
# repository build pathname
BUILD_DIR=/home/www-data/reyboz.it/lab/builds/libre-busto
# document id of the page to be commented
document_id=
# get the branch name
branch_name=asd
if [ -n "$1" ]; then
# it's a Differential revision
branch_name=D"$1"
document_id="$branch_name"
else
# get a ref name (probably "HEAD")
# remotes/origin/bigupdate
remote_shit=$(git name-rev --name-only HEAD)
# bigupdate
branch_name=$(basename "$remote_shit")
fi
# give a name of this built apk
#APK_NAME="$branch_name"-libre-busto-unsigned.apk
APK_NAME="$branch_name"-libre-busto.apk
# complete build URL
BUILD_URL="$EXPECTED_DEPLOY_URL""$APK_NAME"
# pathname to the APK file in the HTTP build directory
BUILD_APK_FILE="$BUILD_DIR"/"$APK_NAME"
# pathname to the git show file in the HTTP build directory
BUILD_GIT_SHOW_FILE="$BUILD_DIR"/"$branch_name"-git-show.txt
echo "Current directory:"
echo " $(pwd)"
echo "Calculating sha256sum of:"
echo " $APK_PATH"
echo "File info"
ls -l "$APK_PATH"
# get the digital signature of the last version
APK_SHA256=$(sha256sum "$APK_PATH" | head -c 64)
# overwrite the latest built APK for this branch name (force date update)
echo "Cleaning old builds"
rm --force "$BUILD_APK_FILE"
cp "$APK_PATH" "$BUILD_APK_FILE"
# overwrite the latest git show for this branch name (force date update)
rm --force "$BUILD_GIT_SHOW_FILE"
git show > "$BUILD_GIT_SHOW_FILE"
echo "Update checksums"
cd "$BUILD_DIR"
rm -f sha1sum.txt
sha1sum * > sha1sum.txt
cd - > /dev/null
# show the build URL in the log
echo "Published here:"
echo "$BUILD_URL"
apix='`'
# Escaping texts for Telegram :(
BUILD_URL_ESCAPED=$(printf "%s" "$BUILD_URL" | sed -E -e 's/\r//g' -e 's/([-"`´,§$%&/(){}#@!?*.\t])/\\\1/g')
APK_NAME_ESCAPED=$(printf "%s" "$APK_NAME" | sed -E -e 's/\r//g' -e 's/([-"`´,§$%&/(){}#@!?*.\t])/\\\1/g')
# add a comment to the build URL
if [ -n "$document_id" ] && [ -z "$NO_COMMENT" ]; then
# We have a Differentials revision under review!
# Escaping text for Telegram :(
# https://github.com/topkecleon/telegram-bot-bash/blob/8f23bca8a1f733aa5d69c648082b59716d7c1fa7/bashbot.sh#L105
document_id_escaped=$(printf "%s" "$document_id" | sed -E -e 's/\r//g' -e 's/([-"`´,§$%&/(){}#@!?*.\t])/\\\1/g')
# Send message to Telegram groups.
telegram_chat_content="⚙ 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"
echo "$telegram_chat_content"
telegram-comment.sh "$TELEGRAM_BOT_TOKEN" "$TELEGRAM_CHAT_ID" "$telegram_chat_content" || true
# Send message to Phorge.
echo "Adding bipbop Comment to $document_id"
phab-comment.php "$document_id" "$BUILD_URL" "$APK_SHA256" || true
else
# We have NOT a Differentials revision under review!
# So this is an atomic commit.
git_commit_title_escaped=$(printf "%s" "$git_commit_title" | sed -E -e 's/\r//g' -e 's/([-"`´,§$%&/(){}#@!?*.\t])/\\\1/g')
# Send message to Telegram groups.
telegram_chat_content="🌚 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"
echo "$telegram_chat_content"
telegram-comment.sh "$TELEGRAM_BOT_TOKEN" "$TELEGRAM_CHAT_ID" "$telegram_chat_content" || true
fi
# delete very old files
echo "Cleaning"
find "$BUILD_DIR" -type f -mtime +120 -delete
# clean old APK in the repository to never re-use it by mistake
# as it happened when we moved everything to the /app directory
rm "$APK_PATH"
echo "Done"

Event Timeline

valerio.bozzolan created this object with edit policy "Libre BustTO hackers (Project)".
valerio.bozzolan edited the content of this paste. (Show Details)