Skip to content

Commit 26aa849

Browse files
committed
Add Android debug build workflow with multi-ABI support
- Automated APK builds for main/develop (releases) and feature branches (artifacts) - Multi-architecture support (armeabi-v7a, arm64-v8a) - Qt 6.9.1 with proper NDK r27c configuration - Dynamic versioning with commit hashes for non-main branches - GitHub releases for main/develop, artifacts for feature branches
1 parent 973c72a commit 26aa849

File tree

3 files changed

+190
-0
lines changed

3 files changed

+190
-0
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Android Debug Build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- develop
8+
- 'feature/**'
9+
- 'feat/**'
10+
- 'bugfix/**'
11+
pull_request:
12+
branches:
13+
- main
14+
- develop
15+
workflow_dispatch:
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
contents: write
22+
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v4
26+
with:
27+
submodules: recursive
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: '17'
33+
distribution: 'temurin'
34+
35+
- name: Setup Android SDK
36+
uses: android-actions/setup-android@v3
37+
38+
- name: Install Qt ARM64
39+
uses: jurplel/install-qt-action@v4
40+
with:
41+
version: '6.9.1'
42+
host: 'linux'
43+
target: 'android'
44+
arch: 'android_arm64_v8a'
45+
modules: 'qtmultimedia'
46+
cache: true
47+
48+
- name: Install Qt ARMv7
49+
uses: jurplel/install-qt-action@v4
50+
with:
51+
version: '6.9.1'
52+
host: 'linux'
53+
target: 'android'
54+
arch: 'android_armv7'
55+
modules: 'qtmultimedia'
56+
cache: true
57+
58+
- name: Install Android NDK
59+
run: |
60+
sdkmanager "ndk;27.2.12479018"
61+
echo "ANDROID_NDK_ROOT=$ANDROID_SDK_ROOT/ndk/27.2.12479018" >> $GITHUB_ENV
62+
63+
- name: Cache CMake build
64+
uses: actions/cache@v4
65+
with:
66+
path: |
67+
android/build
68+
~/.ccache
69+
key: ${{ runner.os }}-cmake-${{ hashFiles('**/CMakeLists.txt') }}
70+
restore-keys: |
71+
${{ runner.os }}-cmake-
72+
73+
- name: Install build dependencies
74+
run: |
75+
sudo apt-get update
76+
sudo apt-get install -y build-essential cmake ninja-build
77+
78+
- name: Initialize Opus submodule
79+
run: |
80+
git submodule update --init --recursive android/3rdparty/opus || echo "Opus submodule not found, will need to be added"
81+
82+
- name: Update version for debug build
83+
if: github.ref_name != 'main'
84+
run: |
85+
SHORT_SHA="${{ github.sha }}"
86+
SHORT_SHA=${SHORT_SHA:0:8}
87+
88+
# Update AndroidManifest.xml (ensure proper escaping)
89+
sed -i "s/android:versionName=\"[^\"]*\"/android:versionName=\"${SHORT_SHA}\"/" android/android/AndroidManifest.xml
90+
91+
# Update ReflectorClient.cpp
92+
sed -i "s/nodeInfoJson\[\"swVer\"\] = \"latry-yo6say-[^\"]*\"/nodeInfoJson[\"swVer\"] = \"latry-yo6say-${SHORT_SHA}\"/" android/ReflectorClient.cpp
93+
94+
# Update Main.qml
95+
sed -i "s/text: 'v[^']*'/text: 'v${SHORT_SHA}'/" android/Main.qml
96+
97+
# Verify changes
98+
echo "=== AndroidManifest.xml ==="
99+
grep "versionName" android/android/AndroidManifest.xml
100+
echo "=== ReflectorClient.cpp ==="
101+
grep "swVer" android/ReflectorClient.cpp
102+
echo "=== Main.qml ==="
103+
grep "text: 'v" android/Main.qml
104+
105+
- name: Configure CMake for Android
106+
working-directory: android
107+
run: |
108+
# Use primary Qt installation (arm64) for qt-cmake
109+
QT_CMAKE_PATH="$QT_ROOT_DIR/bin/qt-cmake"
110+
111+
$QT_CMAKE_PATH -S . -B build \
112+
-DQT_ANDROID_ABIS="armeabi-v7a;arm64-v8a" \
113+
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
114+
-DANDROID_NDK_ROOT=$ANDROID_NDK_ROOT \
115+
-DANDROID_PLATFORM=android-28 \
116+
-DCMAKE_BUILD_TYPE=Debug \
117+
-G Ninja
118+
119+
- name: Build Android APK
120+
working-directory: android
121+
run: |
122+
cmake --build build --target apk
123+
124+
- name: Find and rename APK files
125+
id: find_apk
126+
run: |
127+
APK_PATH=$(find android/build -name "*.apk" -type f | head -1)
128+
if [ -z "$APK_PATH" ]; then
129+
echo "No APK found!"
130+
exit 1
131+
fi
132+
133+
# Create branch-specific APK name
134+
BRANCH_NAME="${{ github.ref_name }}"
135+
SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | sed 's/[^a-zA-Z0-9._-]/_/g')
136+
SHORT_SHA="${{ github.sha }}"
137+
SHORT_SHA=${SHORT_SHA:0:8}
138+
139+
APK_DIR=$(dirname "$APK_PATH")
140+
NEW_APK_NAME="latry-debug-${SAFE_BRANCH_NAME}-${SHORT_SHA}.apk"
141+
NEW_APK_PATH="$APK_DIR/$NEW_APK_NAME"
142+
143+
mv "$APK_PATH" "$NEW_APK_PATH"
144+
145+
echo "apk_path=$NEW_APK_PATH" >> $GITHUB_OUTPUT
146+
echo "apk_name=$NEW_APK_NAME" >> $GITHUB_OUTPUT
147+
148+
- name: Upload APK artifact
149+
uses: actions/upload-artifact@v4
150+
with:
151+
name: ${{ steps.find_apk.outputs.apk_name }}
152+
path: ${{ steps.find_apk.outputs.apk_path }}
153+
retention-days: 90
154+
155+
- name: Create Release for main/develop branches
156+
if: github.event_name == 'push' && (github.ref_name == 'main' || github.ref_name == 'develop')
157+
uses: softprops/action-gh-release@v2
158+
with:
159+
files: ${{ steps.find_apk.outputs.apk_path }}
160+
tag_name: "debug-${{ github.ref_name }}-${{ github.run_number }}"
161+
name: "Debug Build - ${{ github.ref_name }} #${{ github.run_number }}"
162+
body: |
163+
**Debug Build Information**
164+
- Branch: ${{ github.ref_name }}
165+
- Commit: ${{ github.sha }}
166+
- Build: #${{ github.run_number }}
167+
168+
**APK Details**
169+
- Multi-ABI: armeabi-v7a, arm64-v8a
170+
- Version: ${{ github.sha }}
171+
- Signed: Debug keystore
172+
draft: false
173+
prerelease: true
174+
make_latest: false
175+
176+
- name: Add build info to summary
177+
run: |
178+
echo "## Android Debug Build Complete ✅" >> $GITHUB_STEP_SUMMARY
179+
echo "- **Branch:** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
180+
echo "- **Commit:** ${{ github.sha }}" >> $GITHUB_STEP_SUMMARY
181+
echo "- **APK:** ${{ steps.find_apk.outputs.apk_name }}" >> $GITHUB_STEP_SUMMARY
182+
if [[ "${{ github.event_name }}" == "push" && ("${{ github.ref_name }}" == "main" || "${{ github.ref_name }}" == "develop") ]]; then
183+
echo "- **Release:** Created as prerelease" >> $GITHUB_STEP_SUMMARY
184+
else
185+
echo "- **Download:** Available in Actions artifacts" >> $GITHUB_STEP_SUMMARY
186+
fi

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "android/3rdparty/opus"]
2+
path = android/3rdparty/opus
3+
url = https://github.com/xiph/opus.git

android/3rdparty/opus

Submodule opus added at 85c3a49

0 commit comments

Comments
 (0)