prototype for app customization/whitelabeling via custom file #5285
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Android | |
on: | |
push: | |
paths: | |
- 'app/**' | |
- 'core/**' | |
- 'scripts/**' | |
- 'cmake/**' | |
- 'cmake_templates/**' | |
- 'CMakeLists.txt' | |
- '.github/workflows/android.yml' | |
release: | |
types: | |
- published | |
concurrency: | |
group: ci-${{github.ref}}-android | |
cancel-in-progress: true | |
jobs: | |
android_build: | |
if: ( github.repository == 'MerginMaps/mobile' ) && (!contains(github.event.head_commit.message, 'Translate ')) | |
runs-on: macos-13 | |
env: | |
QT_VERSION: '6.6.3' # use scripts/update_qt_version.bash to change | |
NDK_VERSION: r25 | |
NDK_VERSION_FULL: r25b | |
JDK_VERSION: 11 | |
SDK_PLATFORM: android-33 | |
SDK_BUILD_TOOLS: 33.0.1 | |
INPUT_SDK_VERSION_ARM: arm-android-20240517-224 | |
INPUT_SDK_VERSION_ARM64: arm64-android-20240517-224 | |
CCACHE_DIR: /Users/runner/work/ccache | |
GITHUB_TOKEN: ${{ secrets.INPUTAPP_BOT_GITHUB_TOKEN }} | |
CACHE_VERSION: 0 | |
CMAKE_VERSION: '3.29.0' | |
QT_ANDROID_KEYSTORE_ALIAS: input | |
QT_ANDROID_KEYSTORE_KEY_PASS: ${{ secrets.INPUTKEYSTORE_STOREPASS }} | |
QT_ANDROID_KEYSTORE_STORE_PASS: ${{ secrets.INPUTKEYSTORE_STOREPASS }} | |
XC_VERSION: ${{ '15.2' }} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Select latest Xcode | |
run: "sudo xcode-select -s /Applications/Xcode_$XC_VERSION.app" | |
# CCache | |
- name: Prepare build cache for pull request | |
uses: pat-s/[email protected] | |
if: github.event_name == 'pull_request' | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
key: build-android-ccache-${{ github.actor }}-${{ github.head_ref }}-${{ github.sha }} | |
# The head_ref or source branch of the pull request in a workflow run. | |
# The base_ref or target branch of the pull request in a workflow run. | |
restore-keys: | | |
build-android-ccache-${{ github.actor }}-${{ github.head_ref }}- | |
build-android-ccache-refs/heads/${{ github.base_ref }}- | |
build-android-ccache-refs/heads/master- | |
- name: Prepare build cache for branch/tag | |
# use a fork of actions/cache@v2 to upload cache even when the build or test failed | |
uses: pat-s/[email protected] | |
if: github.event_name != 'pull_request' | |
with: | |
path: ${{ env.CCACHE_DIR }} | |
# The branch or tag ref that triggered the workflow run. For branches this in the format refs/heads/<branch_name>, and for tags it is refs/tags/<tag_name> | |
key: build-android-ccache-${{ github.ref }}-${{ github.sha }} | |
restore-keys: | | |
build-android-ccache-${{ github.ref }}- | |
build-android-ccache-refs/heads/master- | |
- name: Install ccache | |
run: | | |
mkdir -p ${CCACHE_DIR} | |
brew install ccache | |
ccache --set-config=max_size=2.0G | |
ccache -s | |
- name: Install Build Dependencies | |
run: | | |
pip3 install -U pip | |
pip3 install aqtinstall | |
brew install gnupg | |
brew install [email protected] | |
brew install ninja | |
if [[ ${{ github.ref }} == refs/tags/* ]] | |
then | |
export GIT_TAG="${GITHUB_REF//refs\/tags\//}" | |
export GIT_BRANCH="" | |
else | |
export GIT_TAG="" | |
export GIT_BRANCH="${GITHUB_REF//refs\/heads\//}" | |
fi | |
echo "GIT_TAG: $GIT_TAG" | |
echo "GIT_BRANCH: $GIT_BRANCH" | |
echo "GIT_TAG=$GIT_TAG" >> $GITHUB_ENV | |
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV | |
- name: Install CMake and Ninja | |
uses: lukka/get-cmake@latest | |
with: | |
cmakeVersion: ${{ env.CMAKE_VERSION }} | |
- name: Cache Qt | |
id: cache-qt | |
uses: pat-s/[email protected] | |
with: | |
path: ${{ github.workspace }}/Qt | |
key: ${{ runner.os }}-QtCache-v6-${{ env.QT_VERSION }}-android | |
- name: Install Qt | |
if: steps.cache-qt.outputs.cache-hit != 'true' | |
run: | | |
aqt install-qt \ | |
mac android ${{ env.QT_VERSION }} android_arm64_v8a \ | |
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \ | |
-O ${{ github.workspace }}/Qt | |
aqt install-qt \ | |
mac android ${{ env.QT_VERSION }} android_armv7 \ | |
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \ | |
-O ${{ github.workspace }}/Qt | |
aqt install-qt \ | |
mac desktop ${{ env.QT_VERSION }} \ | |
-m qtsensors qtconnectivity qt5compat qtmultimedia qtpositioning qtshadertools \ | |
-O ${{ github.workspace }}/Qt | |
# Android SDK & NDK | |
- uses: nttld/setup-ndk@v1 | |
id: setup-ndk | |
with: | |
ndk-version: ${{ env.NDK_VERSION_FULL }} | |
add-to-path: true | |
- name: Set up JDK | |
uses: actions/setup-java@v3 | |
with: | |
java-version: ${{ env.JDK_VERSION }} | |
distribution: zulu | |
- name: Setup Android SDK | |
uses: malinskiy/action-android/install-sdk@release/0.1.4 | |
- name: Install Android Tools | |
run: | | |
sdkmanager --licenses && sdkmanager --verbose "platforms;${SDK_PLATFORM}" "build-tools;${SDK_BUILD_TOOLS}" tools platform-tools | |
# Input SDK | |
- name: Cache Input-SDK | |
id: cache-input-sdk | |
uses: pat-s/[email protected] | |
with: | |
path: ${{ github.workspace }}/input-sdk | |
key: ${{ runner.os }}-input-sdk-v0-${{ env.INPUT_SDK_VERSION_ARM }}-${{ env.CACHE_VERSION }} | |
- name: Install Input-SDK | |
if: steps.cache-input-sdk.outputs.cache-hit != 'true' | |
run: | | |
# download | |
wget -O \ | |
input-sdk-arm-android.tar.gz \ | |
https://github.com/MerginMaps/mobile-sdk/releases/download/${{ env.INPUT_SDK_VERSION_ARM }}/mergin-maps-input-sdk-qt-${{ env.QT_VERSION }}-${{ env.INPUT_SDK_VERSION_ARM }}.tar.gz | |
wget -O \ | |
input-sdk-arm64-android.tar.gz \ | |
https://github.com/MerginMaps/mobile-sdk/releases/download/${{ env.INPUT_SDK_VERSION_ARM64 }}/mergin-maps-input-sdk-qt-${{ env.QT_VERSION }}-${{ env.INPUT_SDK_VERSION_ARM64 }}.tar.gz | |
# unpack | |
mkdir -p ${{ github.workspace }}/input-sdk/arm-android | |
cd ${{ github.workspace }}/input-sdk/arm-android | |
tar -xvzf ${{ github.workspace }}/input-sdk-arm-android.tar.gz | |
mkdir -p ${{ github.workspace }}/input-sdk/arm64-android | |
cd ${{ github.workspace }}/input-sdk/arm64-android | |
tar -xvzf ${{ github.workspace }}/input-sdk-arm64-android.tar.gz | |
# check | |
ls ${{ github.workspace }}/input-sdk | |
- name: Extract Mergin API_KEY | |
env: | |
MERGINSECRETS_DECRYPT_KEY: ${{ secrets.MERGINSECRETS_DECRYPT_KEY }} | |
run: | | |
cd core/ | |
/usr/local/opt/[email protected]/bin/openssl \ | |
aes-256-cbc -d \ | |
-in merginsecrets.cpp.enc \ | |
-out merginsecrets.cpp \ | |
-k "$MERGINSECRETS_DECRYPT_KEY" \ | |
-md md5 | |
- name: Extract GPS keystore | |
env: | |
INPUTKEYSTORE_DECRYPT_KEY: ${{ secrets.INPUTKEYSTORE_DECRYPT_KEY }} | |
run: | | |
/usr/local/opt/[email protected]/bin/openssl \ | |
aes-256-cbc -d \ | |
-in Input_keystore.keystore.enc \ | |
-out Input_keystore.keystore \ | |
-k $INPUTKEYSTORE_DECRYPT_KEY \ | |
-md md5 | |
PATH_TO_KEYSTORE=`pwd`/Input_keystore.keystore | |
echo "path to keystore $PATH_TO_KEYSTORE" | |
echo "QT_ANDROID_KEYSTORE_PATH=$PATH_TO_KEYSTORE" >> $GITHUB_ENV | |
# Build Input App | |
- name: Calculate build number | |
env: | |
OFFFSET: 10 # offset for build number - due to previous builds ~ new builds must always have a higher number | |
run: | | |
BUILD_NUM=$GITHUB_RUN_NUMBER$((GITHUB_RUN_ATTEMPT + OFFFSET)) | |
echo "INPUT_VERSION_CODE=${BUILD_NUM}" >> $GITHUB_ENV | |
echo "Version code: ${BUILD_NUM}" | |
- name: Configure Input | |
env: | |
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
ANDROID_NDK_HOST: darwin-x86_64 | |
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }} | |
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk | |
run: | | |
mkdir -p ${{ github.workspace }}/build-Input | |
cd ${{ github.workspace }}/build-Input | |
cmake \ | |
-DCMAKE_BUILD_TYPE=Release \ | |
-DQT_ANDROID_ABIS="arm64-v8a;armeabi-v7a" \ | |
-DQT_HOST_PATH=$QT_BASE/macos \ | |
-DQT_ANDROID_SIGN_APK=Yes \ | |
-DQT_ANDROID_SIGN_AAB=Yes \ | |
-DCMAKE_TOOLCHAIN_FILE=$QT_BASE/android_arm64_v8a/lib/cmake/Qt6/qt.toolchain.cmake \ | |
-GNinja \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-S ../ \ | |
-B ./ | |
- name: build APK | |
env: | |
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
ANDROID_NDK_HOST: darwin-x86_64 | |
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }} | |
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk | |
run: | | |
cd ${{ github.workspace }}/build-Input | |
ninja apk | |
echo "APKs:" | |
find . | grep .apk | |
- name: Rename APK artefacts | |
run: | | |
mv \ | |
${{ github.workspace }}/build-Input/app/android-build/build/outputs/apk/release/android-build-release-signed.apk \ | |
${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.apk | |
- name: Upload APK to Artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.apk | |
name: Mergin Maps ${{ env.INPUT_VERSION_CODE }} APK [v7 + v8a] | |
- name: build AAB | |
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }} | |
env: | |
ANDROID_NDK_ROOT: ${{ steps.setup-ndk.outputs.ndk-path }} | |
ANDROID_NDK_HOST: darwin-x86_64 | |
QT_BASE: ${{ github.workspace }}/Qt/${{ env.QT_VERSION }} | |
INPUT_SDK_ANDROID_BASE: ${{ github.workspace }}/input-sdk | |
run: | | |
cd ${{ github.workspace }}/build-Input | |
ninja aab | |
echo "AAB:" | |
find . | grep .aab | |
- name: Rename AAB artefacts | |
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }} | |
run: | | |
mv \ | |
${{ github.workspace }}/build-Input/app/android-build/build/outputs/bundle/release/android-build-release.aab \ | |
${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab | |
- name: Upload AAB to Artifacts | |
if: ${{ github.ref_name == 'master' || github.ref_type == 'tag' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
path: ${{ github.workspace }}/merginmaps-${{ env.INPUT_VERSION_CODE }}.aab | |
name: Mergin Maps ${{ env.INPUT_VERSION_CODE }} AAB | |