Skip to content

Merge pull request #6 from kkgit2008/fresh-new_03 #1

Merge pull request #6 from kkgit2008/fresh-new_03

Merge pull request #6 from kkgit2008/fresh-new_03 #1

Workflow file for this run

name: Android Build
### To build from subfolder,just modify the 'ANDROID_DIR'
on:
push:
# branches: [ "main","master","dev","release" ]
### Start build only on these branches
workflow_dispatch:
### Support manual build in 'Actions/workflow'
env:
ANDROID_DIR: .
### Build from project root (when 'app' folder is just at project root)
# ANDROID_DIR: android
### Build from 'android' folder (when 'app' folder is in 'project/android' folder), modify it as you need.
NDK_VERSION: 29.0.13599879
permissions:
contents: write
jobs:
build_apk:
strategy:
matrix:
build_type: ['debug', 'release']
# build_type: ['debug']
name: Build APK
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
uses: styfle/cancel-workflow-action@0.12.1
with:
access_token: ${{ github.token }}
- name: Checkout code
uses: actions/checkout@v4
- name: Cache NDK
uses: actions/cache@v3
id: cache-ndk
with:
path: /usr/local/lib/android/sdk/ndk/${{ env.NDK_VERSION }}
key: ${{ runner.os }}-ndk-${{ env.NDK_VERSION }}
- name: Accept Android licenses and install NDK
if: steps.cache-ndk.outputs.cache-hit != 'true'
run: |
sudo apt-get update && sudo apt-get install -y expect
expect -c '
set timeout 300
spawn /usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager --licenses
### step1: handle Review licenses that have not been accepted (y/N)?"
expect {
"Review licenses that have not been accepted (y/N)?" {
send "y\r"
exp_continue
}
}
### step2: handle all licences
while {[expect {
"Accept? (y/N):" {
send "y\r"
exp_continue
}
### ignore info of progress bar
-re "\[.*\] \d+%.*" {
exp_continue
}
### when finished
eof {
return 1
}
}]} {}
'
### install NDK
/usr/local/lib/android/sdk/cmdline-tools/latest/bin/sdkmanager "ndk;${{ env.NDK_VERSION }}"
shell: bash
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle and build outputs
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
${{ env.ANDROID_DIR }}/app/build
${{ env.ANDROID_DIR }}/app/.cxx ### NDK cache dir
key: ${{ runner.os }}-gradle-${{ hashFiles('**/gradle-wrapper.properties', '**/build.gradle', '**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Increase Gradle memory
working-directory: ${{ env.ANDROID_DIR }}
run: |
printf "\norg.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=1g\n" >> gradle.properties
- name: Make gradlew executable
working-directory: ${{ env.ANDROID_DIR }}
run: |
if [ ! -f "gradlew" ]; then gradle wrapper; fi
chmod +x gradlew
- name: Build ${{ matrix.build_type }} APK
working-directory: ${{ env.ANDROID_DIR }}
run: |
build_type=${{ matrix.build_type }}
./gradlew assemble${build_type^}
- name: Show apk paths
run: |
echo ">>${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}:"
ls -la ${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}
- name: Copy ${{ matrix.build_type }} APK
run: |
cp ${{ env.ANDROID_DIR }}/app/build/outputs/apk/${{ matrix.build_type }}/*.apk ./
- name: Upload ${{ matrix.build_type }} APK
uses: actions/upload-artifact@v4
with:
name: apk-${{ matrix.build_type }}
path: app-${{ matrix.build_type }}.apk