#!/bin/sh ################################################################ # This script just take a built APK and move it to a directory # ################################################################ # # 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 # 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 # repository build pathname BUILD_DIR=/home/www-data/reyboz.it/lab/builds/libre-busto # current directory CURRENT_DIR=$(pwd) # 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" # 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" # add a comment to the build URL if [ -n "$document_id" ] && [ -z "$NO_COMMENT" ]; then echo "Adding bipbop Comment to $document_id" phab-comment.php "$document_id" "$BUILD_URL" "$APK_SHA256" 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"