158 lines
5.3 KiB
YAML
158 lines
5.3 KiB
YAML
name: Android Build
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'carry-your-live/**'
|
|
- '.gitea/workflows/android-build.yml'
|
|
pull_request:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'carry-your-live/**'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
NODE_VERSION: '20'
|
|
JAVA_VERSION: '17'
|
|
ANDROID_HOME: ${{ runner.tool_cache }}/android-sdk
|
|
ANDROID_SDK_ROOT: ${{ runner.tool_cache }}/android-sdk
|
|
|
|
jobs:
|
|
build-android:
|
|
name: Build Android
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'npm'
|
|
cache-dependency-path: carry-your-live/package-lock.json
|
|
|
|
- name: Setup Java
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: ${{ env.JAVA_VERSION }}
|
|
cache: 'gradle'
|
|
cache-dependency-path: carry-your-live/android/gradle/wrapper/gradle-wrapper.properties
|
|
|
|
- name: Install Android SDK
|
|
run: |
|
|
if [ -x "$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" ]; then
|
|
echo "Android SDK already present in cache"
|
|
else
|
|
rm -rf "$ANDROID_HOME/cmdline-tools"
|
|
mkdir -p "$ANDROID_HOME/cmdline-tools"
|
|
wget -q https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip -O /tmp/cmdtools.zip
|
|
unzip -q /tmp/cmdtools.zip -d "$ANDROID_HOME/cmdline-tools"
|
|
mv "$ANDROID_HOME/cmdline-tools/cmdline-tools" "$ANDROID_HOME/cmdline-tools/latest"
|
|
fi
|
|
mkdir -p "$ANDROID_HOME/licenses"
|
|
echo "8933bad161af4178b1185d1a37fbf41ea5269c55" > "$ANDROID_HOME/licenses/android-sdk-license"
|
|
echo "d56f5187479451eabf01fb78af6dfcb131a6481e" >> "$ANDROID_HOME/licenses/android-sdk-license"
|
|
echo "24333f8a63b6825ea9c5514f83c2829b004d1fee" >> "$ANDROID_HOME/licenses/android-sdk-license"
|
|
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" \
|
|
"platform-tools" \
|
|
"platforms;android-36" \
|
|
"build-tools;36.0.0" \
|
|
"ndk;27.1.12297006"
|
|
mkdir -p carry-your-live/android/app
|
|
echo "sdk.dir=$ANDROID_HOME" > carry-your-live/android/app/local.properties
|
|
|
|
- name: Install dependencies
|
|
working-directory: carry-your-live
|
|
run: |
|
|
for i in {1..3}; do
|
|
npm ci && break || sleep 10
|
|
done
|
|
|
|
- name: Prebuild Android
|
|
working-directory: carry-your-live
|
|
run: npx expo prebuild --platform android --clean
|
|
|
|
- name: Build Android Debug APK
|
|
working-directory: carry-your-live/android
|
|
run: ./gradlew assembleDebug --no-daemon
|
|
|
|
- name: Build Android Release APK
|
|
working-directory: carry-your-live/android
|
|
run: ./gradlew assembleRelease --no-daemon
|
|
|
|
- name: Build Android Bundle (AAB)
|
|
working-directory: carry-your-live/android
|
|
run: ./gradlew bundleRelease --no-daemon
|
|
|
|
- name: Run Unit Tests
|
|
working-directory: carry-your-live/android
|
|
run: ./gradlew test --no-daemon
|
|
|
|
- name: Run Lint
|
|
working-directory: carry-your-live/android
|
|
run: ./gradlew lint --no-daemon
|
|
|
|
- name: Find Debug APK
|
|
id: find-debug-apk
|
|
run: |
|
|
APK_PATH=$(find carry-your-live/android/app/build/outputs -name "*debug*.apk" -type f | head -n 1)
|
|
echo "apk_path=$APK_PATH" >> "$GITHUB_OUTPUT"
|
|
echo "Found Debug APK at: $APK_PATH"
|
|
|
|
- name: Find Release APK
|
|
id: find-release-apk
|
|
run: |
|
|
APK_PATH=$(find carry-your-live/android/app/build/outputs -name "*release*.apk" -type f | head -n 1)
|
|
echo "apk_path=$APK_PATH" >> "$GITHUB_OUTPUT"
|
|
echo "Found Release APK at: $APK_PATH"
|
|
|
|
- name: Find Release Bundle (AAB)
|
|
id: find-release-aab
|
|
run: |
|
|
AAB_PATH=$(find carry-your-live/android/app/build/outputs -name "*release*.aab" -type f | head -n 1)
|
|
echo "aab_path=$AAB_PATH" >> "$GITHUB_OUTPUT"
|
|
echo "Found Release AAB at: $AAB_PATH"
|
|
|
|
- name: Upload Debug APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-debug-apk
|
|
path: ${{ steps.find-debug-apk.outputs.apk_path }}
|
|
retention-days: 30
|
|
|
|
- name: Upload Release APK
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-release-apk
|
|
path: ${{ steps.find-release-apk.outputs.apk_path }}
|
|
retention-days: 30
|
|
|
|
- name: Upload Release Bundle (AAB)
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-release-aab
|
|
path: ${{ steps.find-release-aab.outputs.aab_path }}
|
|
retention-days: 30
|
|
|
|
- name: Upload Test Reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-test-reports
|
|
path: carry-your-live/android/app/build/reports/tests/
|
|
retention-days: 14
|
|
|
|
- name: Upload Lint Reports
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: android-lint-reports
|
|
path: carry-your-live/android/app/build/reports/lint-results*.html
|
|
retention-days: 14 |