Compare commits

..

7 commits

Author SHA1 Message Date
fff744a9bb
Fix: remove accidental paste
All checks were successful
continuous-integration/drone/tag Build is passing
2023-02-05 14:00:55 +01:00
26e8360d65
Fix: go back to workspace
Some checks failed
continuous-integration/drone/tag Build is failing
2023-02-05 13:38:15 +01:00
396b88d13c
Fix: remove git pull
Some checks failed
continuous-integration/drone/tag Build is failing
2023-02-05 13:26:38 +01:00
3598c41f07
Feat: use newer openssl libs
Some checks failed
continuous-integration/drone/tag Build is failing
2023-02-05 12:44:39 +01:00
a69a010c7b
Feat: Allow to provide the keystore file as base64 encoded string
All checks were successful
continuous-integration/drone/tag Build is passing
2022-08-04 18:36:47 +02:00
8a961d7e5e
Docs: update README 2022-08-04 17:32:24 +02:00
d39a03c789
Feat: Add support for signing packages
Some checks reported errors
continuous-integration/drone/tag Build was killed
2022-08-04 17:24:53 +02:00
3 changed files with 63 additions and 19 deletions

View file

@ -6,7 +6,7 @@ ARG QT_VERSION="5.15.5"
ARG ANDROID_PLATFORM_VERSION="android-29" ARG ANDROID_PLATFORM_VERSION="android-29"
ARG ANDROID_BUILDTOOLS_VERSION="29.0.2" ARG ANDROID_BUILDTOOLS_VERSION="29.0.2"
ARG ANDROID_NDK_VERSION="21.3.6528147" ARG ANDROID_NDK_VERSION="21.3.6528147"
ARG OPENSSL_VERSION="1.1.1l_1.0.2u" ARG OPENSSL_VERSION="aef7ae2"
WORKDIR /workspace WORKDIR /workspace
@ -27,14 +27,18 @@ RUN echo "**** setup environment ****" && \
echo "**** download Qt and android-cli-tools ****" && \ echo "**** download Qt and android-cli-tools ****" && \
wget -O qt-everywhere.tar.xz ${QT_EVERYWHERE_URL} && \ wget -O qt-everywhere.tar.xz ${QT_EVERYWHERE_URL} && \
wget -O android-cli-tools.zip ${ANDROID_CLI_TOOLS_URL} && \ wget -O android-cli-tools.zip ${ANDROID_CLI_TOOLS_URL} && \
wget -O android_openssl.tar.gz ${ANDROID_OPENSSL_URL} && \
\ \
echo "**** extract Qt and android-cli-tools ****" && \ echo "**** extract Qt and android-cli-tools ****" && \
mkdir qt-everywhere && \ mkdir qt-everywhere && \
tar -xf qt-everywhere.tar.xz --strip-components=1 -C ./qt-everywhere && \ tar -xf qt-everywhere.tar.xz --strip-components=1 -C ./qt-everywhere && \
unzip android-cli-tools.zip && \ unzip android-cli-tools.zip && \
mkdir -p /usr/lib/android-sdk/android_openssl && \ mkdir -p /usr/lib/android-sdk && \
tar -xf android_openssl.tar.gz --strip-components=1 -C /usr/lib/android-sdk/android_openssl && \ \
echo "**** download prebuilt openssl libs ****" && \
git clone https://github.com/KDAB/android_openssl.git /usr/lib/android-sdk/android_openssl && \
cd /usr/lib/android-sdk/android_openssl && \
git checkout "${OPENSSL_VERSION}" && \
cd /workspace && \
\ \
echo "**** install android sdk ****" && \ echo "**** install android sdk ****" && \
echo "y" | ./cmdline-tools/bin/sdkmanager --sdk_root=/usr/lib/android-sdk --install "platform-tools" "platforms;${ANDROID_PLATFORM_VERSION}" "build-tools;${ANDROID_BUILDTOOLS_VERSION}" "ndk;${ANDROID_NDK_VERSION}" && \ echo "y" | ./cmdline-tools/bin/sdkmanager --sdk_root=/usr/lib/android-sdk --install "platform-tools" "platforms;${ANDROID_PLATFORM_VERSION}" "build-tools;${ANDROID_BUILDTOOLS_VERSION}" "ndk;${ANDROID_NDK_VERSION}" && \

View file

@ -8,6 +8,11 @@ The following settings changes this plugin's behavior.
* qmake_arguments (optional) additional arguments for qmake. * qmake_arguments (optional) additional arguments for qmake.
* androiddeployqt_arguments (optional) additional arguments for androiddeployqt. * 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_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. Below is an example `.drone.yml` that uses this plugin.
@ -20,15 +25,21 @@ steps:
image: itsblue.dev/plugins/qt-android image: itsblue.dev/plugins/qt-android
pull: if-not-exists pull: if-not-exists
settings: settings:
qmake_attributes: "CONFIG+=release" qmake_arguments: "CONFIG+=release"
androiddeployqt_attributes: "--aab" androiddeployqt_arguments: "--aab"
src_dir: "."
android_keystore_data:
from_secret: android_keystore_data
android_keystore_alias: "foo"
android_keystore_store_pass:
from_secret: android_keystore_store_pass
``` ```
# Building # Building
Build the plugin image: Build the plugin image:
```text ```bash
docker build -t itsblue.dev/plugins/qt-android -f Dockerfile . docker build -t itsblue.dev/plugins/qt-android -f Dockerfile .
``` ```
@ -36,14 +47,18 @@ docker build -t itsblue.dev/plugins/qt-android -f Dockerfile .
Execute the plugin from your current working directory: Execute the plugin from your current working directory:
```text ```bash
docker run --rm \ docker run --rm \
-e DRONE_COMMIT_SHA=8f51ad7884c5eb69c11d260a31da7a745e6b78e2 \ -e DRONE_COMMIT_SHA=8f51ad7884c5eb69c11d260a31da7a745e6b78e2 \
-e DRONE_COMMIT_BRANCH=master \ -e DRONE_COMMIT_BRANCH=master \
-e DRONE_BUILD_NUMBER=43 \ -e DRONE_BUILD_NUMBER=43 \
-e DRONE_BUILD_STATUS=success \ -e DRONE_BUILD_STATUS=success \
-e PLUGIN_QMAKE_ARGUMENTS="CONFIG+=release" -e PLUGIN_QMAKE_ARGUMENTS="CONFIG+=release" \
-e PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS="--aab" -e PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS="--aab" \
-e PLUGIN_SRC_DIR="." \
-e PLUGIN_ANDROID_KEYSTORE_PATH="android_release.keystore" \
-e PLUGIN_ANDROID_KEYSTORE_ALIAS="foo" \
-e PLUGIN_ANDROID_KEYSTORE_STORE_PASS="strong_password" \
-w /drone/src \ -w /drone/src \
-v $(pwd):/drone/src \ -v $(pwd):/drone/src \
itsblue.dev/plugins/qt-android itsblue.dev/plugins/qt-android

View file

@ -1,21 +1,46 @@
#!/bin/bash #!/bin/bash
set -e set -e
[[ -z "${PLUGIN_QMAKE_ARGUMENTS}" ]] && QMAKE_ARGUMENTS=$1 || QMAKE_ARGUMENTS="${PLUGIN_QMAKE_ARGUMENTS}" [[ -z "${PLUGIN_QMAKE_ARGUMENTS}" ]] && QMAKE_ARGUMENTS="" || QMAKE_ARGUMENTS="${PLUGIN_QMAKE_ARGUMENTS}"
[[ -z "${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}" ]] && ANDROIDDEPLOYQT_ARGUMENTS=$2 || ANDROIDDEPLOYQT_ARGUMENTS="${PLUGIN_ANDROIDDEPLOYQT_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_SRC_DIR}" ]] && SRC_DIR=$(pwd) || SRC_DIR=$(realpath "${PLUGIN_SRC_DIR}")
[[ -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=${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}"
echo "* SRC_DIR=${SRC_DIR}"
echo "**********************"
echo ""
echo "**** prepare ****" echo "**** prepare ****"
rm -rf /build rm -rf /build
mkdir -p /build mkdir -p /build
cd /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 ****" echo "**** qmake ****"
qmake $QMAKE_ARGUMENTS $SRC_DIR qmake $QMAKE_ARGUMENTS $SRC_DIR
@ -24,7 +49,7 @@ make -j8
make INSTALL_ROOT=/build/android-build install make INSTALL_ROOT=/build/android-build install
echo "**** android build ****" echo "**** android build ****"
androiddeployqt --input $(ls -1 /build/android-*-deployment-settings.json) --output /build/android-build --gradle $ANDROIDDEPLOYQT_ARGUMENTS androiddeployqt --input $(ls -1 /build/android-*-deployment-settings.json) --output /build/android-build $ANDROIDDEPLOYQT_ARGUMENTS
echo "**** finish up ****" echo "**** finish up ****"
mv /build/android-build//build/outputs $SRC_DIR/outputs mv /build/android-build//build/outputs $SRC_DIR/outputs