Compare commits
17 commits
Author | SHA1 | Date | |
---|---|---|---|
fff744a9bb | |||
26e8360d65 | |||
396b88d13c | |||
3598c41f07 | |||
a69a010c7b | |||
8a961d7e5e | |||
d39a03c789 | |||
b94f9727ad | |||
b5e6329f0f | |||
448535608f | |||
293c0973ba | |||
b84297906a | |||
7226c4a718 | |||
cdb9e27cc8 | |||
c1e08e3e4d | |||
81c16e66e2 | |||
31ab1d8235 |
4 changed files with 89 additions and 19 deletions
13
.drone.yml
13
.drone.yml
|
@ -12,4 +12,15 @@ steps:
|
|||
username:
|
||||
from_secret: docker_username
|
||||
password:
|
||||
from_secret: docker_password
|
||||
from_secret: docker_password
|
||||
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
base_url: https://itsblue.dev
|
||||
api_key:
|
||||
from_secret: docker_password
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/tags/v*
|
10
Dockerfile
10
Dockerfile
|
@ -6,6 +6,7 @@ ARG QT_VERSION="5.15.5"
|
|||
ARG ANDROID_PLATFORM_VERSION="android-29"
|
||||
ARG ANDROID_BUILDTOOLS_VERSION="29.0.2"
|
||||
ARG ANDROID_NDK_VERSION="21.3.6528147"
|
||||
ARG OPENSSL_VERSION="aef7ae2"
|
||||
|
||||
WORKDIR /workspace
|
||||
|
||||
|
@ -15,6 +16,7 @@ RUN echo "**** setup environment ****" && \
|
|||
export PATH=$QT_INSTALL_DIR/bin:$JAVA_HOME/bin:$PATH && \
|
||||
export QT_EVERYWHERE_URL="https://download.qt.io/archive/qt/${QT_VERSION_FAMILY}/${QT_VERSION}/single/qt-everywhere-opensource-src-${QT_VERSION}.tar.xz" && \
|
||||
export ANDROID_CLI_TOOLS_URL="https://dl.google.com/android/repository/commandlinetools-linux-8512546_latest.zip" && \
|
||||
export ANDROID_OPENSSL_URL="https://github.com/KDAB/android_openssl/archive/refs/tags/${OPENSSL_VERSION}.tar.gz" && \
|
||||
\
|
||||
echo "**** install dependencies ****" && \
|
||||
dpkg --add-architecture i386 && \
|
||||
|
@ -30,6 +32,13 @@ RUN echo "**** setup environment ****" && \
|
|||
mkdir qt-everywhere && \
|
||||
tar -xf qt-everywhere.tar.xz --strip-components=1 -C ./qt-everywhere && \
|
||||
unzip android-cli-tools.zip && \
|
||||
mkdir -p /usr/lib/android-sdk && \
|
||||
\
|
||||
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 "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}" && \
|
||||
|
@ -58,6 +67,7 @@ RUN echo "**** setup environment ****" && \
|
|||
echo "**** done ****"
|
||||
|
||||
ENV PATH="${PATH}:/usr/lib/qt/bin:/usr/lib/jvm/java-8-openjdk-amd64/bin"
|
||||
ENV ANDROID_HOME=/usr/lib/android-sdk
|
||||
WORKDIR /src
|
||||
|
||||
COPY "qt-build" "/usr/local/bin/qt-build"
|
||||
|
|
39
README.md
39
README.md
|
@ -8,6 +8,11 @@ The following settings changes this plugin's behavior.
|
|||
|
||||
* qmake_arguments (optional) additional arguments for qmake.
|
||||
* 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.
|
||||
|
||||
|
@ -20,15 +25,21 @@ steps:
|
|||
image: itsblue.dev/plugins/qt-android
|
||||
pull: if-not-exists
|
||||
settings:
|
||||
qmake_attributes: "CONFIG+=release"
|
||||
androiddeployqt_attributes: "--aab"
|
||||
qmake_arguments: "CONFIG+=release"
|
||||
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
|
||||
|
||||
Build the plugin image:
|
||||
|
||||
```text
|
||||
```bash
|
||||
docker build -t itsblue.dev/plugins/qt-android -f Dockerfile .
|
||||
```
|
||||
|
||||
|
@ -36,15 +47,29 @@ docker build -t itsblue.dev/plugins/qt-android -f Dockerfile .
|
|||
|
||||
Execute the plugin from your current working directory:
|
||||
|
||||
```text
|
||||
docker run --rm -e PLUGIN_FOLDER=public -e PLUGIN_SSH_KEY=foo \
|
||||
```bash
|
||||
docker run --rm \
|
||||
-e DRONE_COMMIT_SHA=8f51ad7884c5eb69c11d260a31da7a745e6b78e2 \
|
||||
-e DRONE_COMMIT_BRANCH=master \
|
||||
-e DRONE_BUILD_NUMBER=43 \
|
||||
-e DRONE_BUILD_STATUS=success \
|
||||
-e PLUGIN_QMAKE_ARGUMENTS="CONFIG+=release"
|
||||
-e PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS="--aab"
|
||||
-e PLUGIN_QMAKE_ARGUMENTS="CONFIG+=release" \
|
||||
-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 \
|
||||
-v $(pwd):/drone/src \
|
||||
itsblue.dev/plugins/qt-android
|
||||
```
|
||||
|
||||
# Using openssl
|
||||
|
||||
This image includes [prebuilt openssl libraries](https://github.com/KDAB/android_openssl). You may include them in your .pro file like so:
|
||||
```pro
|
||||
android {
|
||||
ANDROID_HOME = $$(ANDROID_HOME)
|
||||
include($$ANDROID_HOME/android_openssl/openssl.pri)
|
||||
}
|
||||
```
|
||||
|
|
46
qt-build
46
qt-build
|
@ -1,22 +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="" || 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}"
|
||||
|
||||
SRC_DIR=$(pwd)
|
||||
|
||||
echo "**** environment: ****"
|
||||
echo "* QMAKE_ARGUMENTS=${QMAKE_ARGUMENTS}"
|
||||
echo "* ANDROIDDEPLOYQT_ARGUMENTS=${PLUGIN_ANDROIDDEPLOYQT_ARGUMENTS}"
|
||||
echo "* SRC_DIR=${SRC_DIR}"
|
||||
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
|
||||
|
||||
|
@ -25,7 +49,7 @@ make -j8
|
|||
make INSTALL_ROOT=/build/android-build install
|
||||
|
||||
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 ****"
|
||||
mv /build/android-build//build/outputs $SRC_DIR/outputs
|
||||
|
|
Loading…
Reference in a new issue