-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (119 loc) · 4.41 KB
/
Copy pathandroid-build.yml
File metadata and controls
139 lines (119 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: Android Build
on:
push:
branches: [main, master]
paths:
- 'android/**'
- '.github/workflows/android-build.yml'
pull_request:
branches: [main, master]
paths:
- 'android/**'
- '.github/workflows/android-build.yml'
workflow_dispatch:
jobs:
lint-and-test:
name: Lint & Unit Tests
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Install Gradle & Android SDK
run: |
# Install Gradle 8.7
wget -q https://services.gradle.org/distributions/gradle-8.7-bin.zip -O /tmp/gradle.zip
sudo unzip -q /tmp/gradle.zip -d /opt
# Setup Android SDK
export ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
ls -la $ANDROID_SDK_ROOT/platforms/ 2>/dev/null || echo "Initial platforms: (empty)"
# Install required SDK components
if [ -f "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses 2>/dev/null || true
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager \
"platforms;android-34" \
"build-tools;34.0.0" 2>&1 | tail -5
fi
# Create local.properties
echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
echo "Gradle installed. Android SDK ready."
- name: Run unit tests
working-directory: android
run: /opt/gradle-8.7/bin/gradle testDebugUnitTest 2>&1 | tail -60
env:
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
- name: Upload test reports
uses: actions/upload-artifact@v4
if: failure()
with:
name: test-reports
path: android/app/build/reports/tests/
retention-days: 7
build-apk:
name: Build Debug APK
runs-on: ubuntu-22.04
needs: lint-and-test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
- name: Install Gradle & Android SDK
run: |
# Install Gradle 8.7
wget -q https://services.gradle.org/distributions/gradle-8.7-bin.zip -O /tmp/gradle.zip
sudo unzip -q /tmp/gradle.zip -d /opt
# Setup Android SDK
export ANDROID_SDK_ROOT=/usr/local/lib/android/sdk
echo "ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"
# Install required SDK components
if [ -f "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
yes | $ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager --licenses 2>/dev/null || true
$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager \
"platforms;android-34" \
"build-tools;34.0.0" 2>&1 | tail -5
fi
echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
- name: Build APK
working-directory: android
run: |
echo "=== SDK Config ==="
cat local.properties
echo "=== Gradle Version ==="
/opt/gradle-8.7/bin/gradle --version 2>&1 | head -3
echo "=== Building ==="
set -o pipefail
/opt/gradle-8.7/bin/gradle assembleDebug --stacktrace --no-daemon 2>&1 | tee /tmp/build.log
env:
ANDROID_SDK_ROOT: /usr/local/lib/android/sdk
- name: Show build errors
if: failure()
run: |
echo "=== Last 200 lines ==="
tail -200 /tmp/build.log
echo "=== Error markers ==="
grep -iE 'error:|FAILED|Unresolved|Exception|BUILD FAILED|cannot find' /tmp/build.log || echo "(no markers)"
- name: List APK directory
if: always()
run: find android/app/build/outputs/apk/ -type f 2>/dev/null || echo "(dir not found)"
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: app-debug
path: android/app/build/outputs/apk/debug/app-debug.apk
retention-days: 30
- name: Upload build log
uses: actions/upload-artifact@v4
if: always()
with:
name: build-log
path: /tmp/build.log
retention-days: 7