diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml new file mode 100644 index 00000000..85bb5a3e --- /dev/null +++ b/.github/workflows/android.yml @@ -0,0 +1,49 @@ +name: Android CI + +on: + push: + branches: [ "master", "android_ci" ] + pull_request: + branches: [ "master", "android_ci" ] + +jobs: + + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - uses: nttld/setup-ndk@v1.4.2 + id: setup-ndk + with: + ndk-version: r26d + link-to-sdk: true + add-to-path: true + - name: set up JDK 11 + uses: actions/setup-java@v3 + with: + java-version: '11' + distribution: 'temurin' + cache: gradle + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Build Release Without Video Module + run: ./tasks.sh --enable-cmake --release --disable-video-module --build + - name: Save build artifacts - Release Without Video Module + run: mv $(find "cgeDemo/build" -iname "*.apk" | grep release) demoRelease/cgeDemo_NoVideoRecord.apk + - name: Build Release With Video Module + run: ./tasks.sh --clean --enable-cmake --release --enable-video-module --build + - name: Save build artifacts - Release With Video Module + run: mv $(find "cgeDemo/build" -iname "*.apk" | grep release) demoRelease/cgeDemo.apk + - name: lint + run: ./gradlew lint + - name: upload artifacts + uses: actions/upload-artifact@v4 + with: + name: my-artifact + path: | + demoRelease/cgeDemo_NoVideoRecord.apk + demoRelease/cgeDemo.apk + compression-level: 0 + retention-days: 15 + if-no-files-found: error diff --git a/settings.gradle b/settings.gradle index 54285bd6..576a42d1 100644 --- a/settings.gradle +++ b/settings.gradle @@ -2,7 +2,11 @@ include ':library', ':cgeDemo' def pFile = new File(settingsDir, 'local.properties') Properties properties = new Properties() -properties.load(pFile.newDataInputStream()) + +/// if the local.properties file does not exist, create it. +if (pFile.exists()) { + properties.load(pFile.newDataInputStream()) +} if (properties.getProperty('usingCMakeCompile', null) == null) { pFile.append('\nusingCMakeCompile=false\n') diff --git a/tasks.sh b/tasks.sh index c1154706..83ed6181 100755 --- a/tasks.sh +++ b/tasks.sh @@ -127,15 +127,15 @@ while [[ $# > 0 ]]; do shift ;; --release) - ANDROID_BUILD_TYPE="assembleRelease" + export ANDROID_BUILD_TYPE="assembleRelease" # ANDROID_BUILD_TYPE="assembleDebug" # use this if the release apk can not be installed. - GRADLEW_RUN_TASK="installRelease" + export GRADLEW_RUN_TASK="installRelease" changeProperty "local.properties" '^usingCMakeCompileDebug=' 's/usingCMakeCompileDebug=.*/usingCMakeCompileDebug=false/' 'usingCMakeCompileDebug=false' shift ;; --debug) - ANDROID_BUILD_TYPE="assembleDebug" - GRADLEW_RUN_TASK="installDebug" + export ANDROID_BUILD_TYPE="assembleDebug" + export GRADLEW_RUN_TASK="installDebug" changeProperty "local.properties" '^usingCMakeCompileDebug=' 's/usingCMakeCompileDebug=.*/usingCMakeCompileDebug=true/' 'usingCMakeCompileDebug=true' shift ;;