From 16c2e272a4d37427eeeb7d5c91470727f334d0e6 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 7 Feb 2024 15:52:37 -0800 Subject: [PATCH] try --- .github/workflows/example.yml | 46 +++++++++++++++++++++++++------- .github/workflows/tests.yml | 4 +-- example/android/app/build.gradle | 10 +++++++ example/android/build.gradle | 16 ++++++++++- 4 files changed, 64 insertions(+), 12 deletions(-) diff --git a/.github/workflows/example.yml b/.github/workflows/example.yml index e89978c..02cf216 100644 --- a/.github/workflows/example.yml +++ b/.github/workflows/example.yml @@ -5,15 +5,17 @@ on: push: branches: [ main ] paths: - - '.github/workflows/example.yml' - - 'example/**' + - '**' - '!example/README.md' + - '!README.md' + - '!test/**' pull_request: branches: [ main, 'v[0-9]+.[0-9]+' ] paths: - - '.github/workflows/example.yml' - - 'example/**' + - '**' - '!example/README.md' + - '!README.md' + - '!test/**' jobs: build-android: @@ -22,6 +24,19 @@ jobs: strategy: matrix: node-version: [16.x, 18.x, 20.x] + include: + - node-version: 16.x + gradle-version: 6.5 + agp-version: 4.1.3 + java-version: 11 + - node-version: 18.x + gradle-version: 7.5 + agp-version: 7.4.2 + java-version: 11 + - node-version: 20.x + gradle-version: 8.2 + agp-version: 8.2.2 + java-version: 17 steps: - uses: actions/checkout@v3 @@ -31,12 +46,28 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Pre-build dependencies - run: npm install yarn + - name: Use JDK ${{ matrix.java-version }} + uses: actions/setup-java@v4 + with: + java-version: ${{ matrix.java-version }} + distribution: 'temurin' + + - name: Use Gradle ${{ matrix.gradle-version }} + uses: gradle/actions/setup-gradle@v3 + with: + gradle-version: ${{ matrix.gradle-version }} + + - name: Inject AGP version + run: echo agpVersion="${{ matrix.agp-version }}" >> local.properties + working-directory: example/android - name: Install dependencies run: yarn bootstrap + - name: Generate gradle wrapper + run: gradle wrapper --gradle-version ${{ matrix.gradle-version }} --distribution-type all + working-directory: example/android + - name: Build bundle run: yarn example android-bundle @@ -59,9 +90,6 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Pre-build dependencies - run: npm install yarn - - name: Install dependencies run: yarn bootstrap diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 10c4c62..49e5f33 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -7,13 +7,13 @@ on: paths: - '**' - '!README.md' - - '!example/README.md' + - '!example/**' pull_request: branches: [ main, 'v[0-9]+.[0-9]+' ] paths: - '**' - '!README.md' - - '!example/README.md' + - '!example/**' defaults: run: diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index d570ae9..f7b0234 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -89,6 +89,16 @@ def reactNativeArchitectures() { } android { + def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION + if (agpVersion.tokenize('.')[0].toInteger() >= 7) { + namespace "ai.picovoice.reactnative.voiceprocessorexample" + } + + if (agpVersion.tokenize('.')[0].toInteger() >= 8) { + buildFeatures { + buildConfig = true + } + } compileSdk rootProject.ext.compileSdkVersion namespace "ai.picovoice.reactnative.voiceprocessorexample" diff --git a/example/android/build.gradle b/example/android/build.gradle index 148d08f..adf1606 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -11,8 +11,22 @@ buildscript { google() mavenCentral() } + + def localProperties = new Properties() + def localPropertiesFile = rootProject.file('local.properties') + if (localPropertiesFile.exists()) { + localPropertiesFile.withReader('UTF-8') { reader -> + localProperties.load(reader) + } + } + + def agpVersion = localProperties.getProperty('agpVersion') + if (agpVersion == null) { + agpVersion = '7.4.2' + } + dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath "com.android.tools.build:gradle:$agpVersion" classpath 'com.facebook.react:react-native-gradle-plugin' } }