diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 547e1f1c..3cf70b69 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ on: push: tags: - 'v*' - + jobs: Build: name: Build/Sign APK @@ -17,7 +17,12 @@ jobs: BUILD_TOOL_VERSION=$(ls /usr/local/lib/android/sdk/build-tools/ | tail -n 1) echo "BUILD_TOOL_VERSION=$BUILD_TOOL_VERSION" >> $GITHUB_ENV echo Last build tool version is: $BUILD_TOOL_VERSION - + + - name: Access GOOGLE_API_KEY + env: + GOOGLE_API_KEY: $ + run: echo GOOGLE_API_KEY=\"$GOOGLE_API_KEY\" >> ./local.properties + - name: set up JDK 17 uses: actions/setup-java@v3 with: @@ -65,7 +70,7 @@ jobs: keyPassword: ${{ secrets.KEY_PASSWORD }} env: BUILD_TOOLS_VERSION: ${{ env.BUILD_TOOL_VERSION }} - + - name: Make artifact uses: actions/upload-artifact@v2 with: diff --git a/app/build.gradle b/app/build.gradle index 3e9359bd..2d4f9bdf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -8,6 +8,17 @@ plugins { apply plugin: 'com.mikepenz.aboutlibraries.plugin' +String getGoogleApiKey() { + def propFile = rootProject.file("./local.properties") + def properties = new Properties() + if (propFile.exists()) { + properties.load(new FileInputStream(propFile)) + return properties.getProperty('GOOGLE_API_KEY', "null") + } else { + return "null" + } +} + android { namespace 'com.starry.myne' compileSdk 34 @@ -27,6 +38,8 @@ android { ksp { arg('room.schemaLocation', "$projectDir/schemas") } + + buildConfigField("String", "GOOGLE_API_KEY", getGoogleApiKey()) } buildTypes { @@ -85,7 +98,7 @@ dependencies { implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.7.0' implementation 'androidx.activity:activity-compose:1.8.2' implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0" - implementation "androidx.navigation:navigation-compose:2.7.6" + implementation "androidx.navigation:navigation-compose:2.7.7" // Jetpack compose. implementation "androidx.compose.ui:ui" implementation "androidx.compose.ui:ui-tooling-preview" diff --git a/app/src/main/java/com/starry/myne/repo/BookRepository.kt b/app/src/main/java/com/starry/myne/repo/BookRepository.kt index 1aa88df6..43a4bb9e 100644 --- a/app/src/main/java/com/starry/myne/repo/BookRepository.kt +++ b/app/src/main/java/com/starry/myne/repo/BookRepository.kt @@ -17,6 +17,7 @@ package com.starry.myne.repo import com.google.gson.Gson +import com.starry.myne.BuildConfig import com.starry.myne.repo.models.BookSet import com.starry.myne.repo.models.ExtraInfo import com.starry.myne.utils.book.BookLanguage @@ -41,7 +42,9 @@ class BookRepository { private val baseApiUrl = "https://myne.pooloftears.xyz/books" private val googleBooksUrl = "https://www.googleapis.com/books/v1/volumes" - private val googleApiKey = "AIzaSyBCaXx-U0sbEpGVPWylSggC4RaR4gCGkVE" + private val googleApiKey = + BuildConfig.GOOGLE_API_KEY ?: "AIzaSyBCaXx-U0sbEpGVPWylSggC4RaR4gCGkVE" // Backup API key + private val okHttpClient = OkHttpClient.Builder() .connectTimeout(60, TimeUnit.SECONDS)