Feat: Allow to provide the keystore file as base64 encoded string
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
Dorian Zedler 2022-08-04 18:36:47 +02:00
parent 8a961d7e5e
commit a69a010c7b
Signed by: dorian
GPG key ID: 989DE36109AFA354
2 changed files with 37 additions and 22 deletions

View file

@ -10,7 +10,8 @@ The following settings changes this plugin's behavior.
* androiddeployqt_arguments (optional) additional arguments for androiddeployqt.
* src_dir (optional) the path to the source directory
* android_keystore_path (optional) the path to the android_keystore file.
* android_keystore_alias (required, if android_keystore_path is set) the keystore alias.
* android_keystore_data (optional, secret recommended) the keystore file encoded as base64. If set, android_keystore_path will be ignored!
* android_keystore_alias (required, if android_keystore_path or android_keystore_data is set) the keystore alias.
* android_keystore_store_pass (optional, secret recommended) the password for the keystore.
Below is an example `.drone.yml` that uses this plugin.
@ -27,7 +28,8 @@ steps:
qmake_arguments: "CONFIG+=release"
androiddeployqt_arguments: "--aab"
src_dir: "."
android_keystore_path: "android_release.keystore"
android_keystore_data:
from_secret: android_keystore_data
android_keystore_alias: "foo"
android_keystore_store_pass:
from_secret: android_keystore_store_pass

View file

@ -1,25 +1,46 @@
#!/bin/bash
set -e
[[ -z "${PLUGIN_QMAKE_ARGUMENTS}" ]] && QMAKE_ARGUMENTS=$1 || QMAKE_ARGUMENTS="${PLUGIN_QMAKE_ARGUMENTS}"
[[ -z "${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}" ]] && ANDROIDDEPLOYQT_ARGUMENTS=$2 || ANDROIDDEPLOYQT_ARGUMENTS="${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}"
[[ -z "${PLUGIN_QMAKE_ARGUMENTS}" ]] && QMAKE_ARGUMENTS="" || QMAKE_ARGUMENTS="${PLUGIN_QMAKE_ARGUMENTS}"
[[ -z "${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}" ]] && ANDROIDDEPLOYQT_ARGUMENTS="" || ANDROIDDEPLOYQT_ARGUMENTS="${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}"
[[ -z "${PLUGIN_SRC_DIR}" ]] && SRC_DIR=$(pwd) || SRC_DIR=$(realpath "${PLUGIN_SRC_DIR}")
[[ -z "${PLUGIN_ANDROID_KEYSTORE_PATH}" ]] && ANDROID_KEYSTORE_PATH=$3 || ANDROID_KEYSTORE_PATH=$(realpath "${PLUGIN_ANDROID_KEYSTORE_PATH}")
[[ -z "${PLUGIN_ANDROID_KEYSTORE_ALIAS}" ]] && ANDROID_KEYSTORE_ALIAS=$4 || ANDROID_KEYSTORE_ALIAS="${PLUGIN_ANDROID_KEYSTORE_ALIAS}"
[[ -z "${PLUGIN_ANDROID_KEYSTORE_STORE_PASS}" ]] && ANDROID_KEYSTORE_STORE_PASS=$5 || ANDROID_KEYSTORE_STORE_PASS="${PLUGIN_ANDROID_KEYSTORE_STORE_PASS}"
[[ -z "${PLUGIN_ANDROID_KEYSTORE_PATH}" ]] && ANDROID_KEYSTORE_PATH="" || ANDROID_KEYSTORE_PATH=$(realpath "${PLUGIN_ANDROID_KEYSTORE_PATH}")
[[ -z "${PLUGIN_ANDROID_KEYSTORE_DATA}" ]] && ANDROID_KEYSTORE_DATA="" || ANDROID_KEYSTORE_DATA="${PLUGIN_ANDROID_KEYSTORE_DATA}"
[[ -z "${PLUGIN_ANDROID_KEYSTORE_ALIAS}" ]] && ANDROID_KEYSTORE_ALIAS="" || ANDROID_KEYSTORE_ALIAS="${PLUGIN_ANDROID_KEYSTORE_ALIAS}"
[[ -z "${PLUGIN_ANDROID_KEYSTORE_STORE_PASS}" ]] && ANDROID_KEYSTORE_STORE_PASS="" || ANDROID_KEYSTORE_STORE_PASS="${PLUGIN_ANDROID_KEYSTORE_STORE_PASS}"
echo "**** environment: ****"
echo "* QMAKE_ARGUMENTS=${QMAKE_ARGUMENTS}"
echo "* ANDROIDDEPLOYQT_ARGUMENTS=${ANDROIDDEPLOYQT_ARGUMENTS}"
echo "* SRC_DIR=${SRC_DIR}"
echo "* ANDROID_KEYSTORE_PATH=${ANDROID_KEYSTORE_PATH}"
echo "**********************"
echo ""
echo "**** prepare ****"
rm -rf /build
mkdir -p /build
cd /build
echo ""
echo "**** environment: ****"
echo "* QMAKE_ARGUMENTS=${QMAKE_ARGUMENTS}"
echo "* ANDROIDDEPLOYQT_ARGUMENTS=${ANDROIDDEPLOYQT_ARGUMENTS}"
echo "* SRC_DIR=${SRC_DIR}"
# handle signing stuff
if ( [ -n "$ANDROID_KEYSTORE_DATA" ] || [ -n "$ANDROID_KEYSTORE_PATH" ] ) && [ -n "$ANDROID_KEYSTORE_ALIAS" ]; then
if [ -n "$ANDROID_KEYSTORE_DATA" ]; then
echo $ANDROID_KEYSTORE_DATA | tr ' ' '\n' | base64 -d > /build/android_release.keystore
ANDROID_KEYSTORE_PATH=/build/android_release.keystore
echo "* SIGNING with keystore from provided data"
else
echo "* SIGNING with keystore $ANDROID_KEYSTORE_PATH"
fi
ANDROIDDEPLOYQT_ARGUMENTS="$ANDROIDDEPLOYQT_ARGUMENTS --sign $ANDROID_KEYSTORE_PATH $ANDROID_KEYSTORE_ALIAS"
if [ -n "$ANDROID_KEYSTORE_STORE_PASS" ]; then
ANDROIDDEPLOYQT_ARGUMENTS="$ANDROIDDEPLOYQT_ARGUMENTS --storepass $ANDROID_KEYSTORE_STORE_PASS"
fi
else
echo "* NO signing"
fi
echo "**********************"
echo ""
echo "**** qmake ****"
qmake $QMAKE_ARGUMENTS $SRC_DIR
@ -28,14 +49,6 @@ make -j8
make INSTALL_ROOT=/build/android-build install
echo "**** android build ****"
# inject signing stuff
if [ -n "$ANDROID_KEYSTORE_PATH" ] && [ -n "$ANDROID_KEYSTORE_ALIAS" ]; then
ANDROIDDEPLOYQT_ARGUMENTS="$ANDROIDDEPLOYQT_ARGUMENTS --sign $ANDROID_KEYSTORE_PATH $ANDROID_KEYSTORE_ALIAS"
if [ -n "$ANDROID_KEYSTORE_STORE_PASS" ]; then
ANDROIDDEPLOYQT_ARGUMENTS="$ANDROIDDEPLOYQT_ARGUMENTS --storepass $ANDROID_KEYSTORE_STORE_PASS"
fi
fi
androiddeployqt --input $(ls -1 /build/android-*-deployment-settings.json) --output /build/android-build $ANDROIDDEPLOYQT_ARGUMENTS
echo "**** finish up ****"