From c739e5ff075b58560ebe32a232640b8e5930253e Mon Sep 17 00:00:00 2001 From: ZakirSheikh Date: Wed, 23 Aug 2023 14:44:31 +0530 Subject: [PATCH] test94 --- .github/workflows/test.yml | 14 ++++----- app/build.gradle.kts | 60 ++++++++++++++------------------------ 2 files changed, 29 insertions(+), 45 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eed625f..df95b39 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,14 +12,14 @@ jobs: - name: Setting environment variables for date, ads, unity, and version run: > echo "DATE_TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - echo "IAP_NO_ADS=$(echo ${{ secrets.IAP_NO_ADS }})" >> $GITHUB_ENV - echo "PLACEMENT_BANNER_1=$(echo ${{ secrets.PLACEMENT_BANNER_1 }})" >> $GITHUB_ENV - echo "PLACEMENT_BANNER_1=$(echo ${{ secrets.PLACEMENT_BANNER_1 }})" >> $GITHUB_ENV - echo "PLACEMENT_BANNER_2=$(echo ${{ secrets.PLACEMENT_BANNER_2 }})" >> $GITHUB_ENV - echo "PLACEMENT_INTERSTITIAL=$(echo ${{ secrets.PLACEMENT_INTERSTITIAL }})" >> $GITHUB_ENV - echo "PLAY_CONSOLE_APP_RSA_KEY=$(echo ${{ secrets.PLAY_CONSOLE_APP_RSA_KEY }})" >> $GITHUB_ENV - echo "UNITY_APP_ID=$(echo ${{ secrets.UNITY_APP_ID }})" >> $GITHUB_ENV echo "GIT_TAG=$(grep -E "versionName\s*=?\s*['\"]" "app/build.gradle.kts" | awk -F"['\"]" '{print $2}')" >> $GITHUB_ENV + echo "IAP_NO_ADS=${{ secrets.IAP_NO_ADS }}" >> local.properties + echo "PLACEMENT_BANNER_1=${{ secrets.PLACEMENT_BANNER_1 }}" >> local.properties + echo "PLACEMENT_BANNER_2=${{ secrets.PLACEMENT_BANNER_2 }}" >> local.properties + echo "PLACEMENT_INTERSTITIAL=${{ secrets.PLACEMENT_INTERSTITIAL }}" >> local.properties + echo "PLAY_CONSOLE_APP_RSA_KEY=${{ secrets.PLAY_CONSOLE_APP_RSA_KEY }}" >> local.properties + echo "UNITY_APP_ID=${{ secrets.UNITY_APP_ID }}" >> local.properties + - name: Configuring Java environment with Zulu JDK 17 and Gradle cache, uses: actions/setup-java@v3 with: diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 79433dc..c08f93c 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,4 +1,5 @@ import com.android.build.api.dsl.ApplicationDefaultConfig +import java.util.Properties plugins { alias(libs.plugins.androidApplication) @@ -21,9 +22,8 @@ android { versionName = "1.0.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } - // Add necessary const to BuildConfig - // These filed will be provided in github - // secrets when released else defualt value will be used + // Load secret keys from properties of Local Config. + // The local properties must be prefixed with secret. secrets() } buildTypes { @@ -131,39 +131,23 @@ dependencies { * Init adn add git secrets to BuildConfig */ fun ApplicationDefaultConfig.secrets() { - buildConfigField( - "String", - "IAP_BUY_ME_COFFEE", - "\"" + (System.getenv("IAP_BUY_ME_COFFEE") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "IAP_NO_ADS", - "\"" + (System.getenv("IAP_NO_ADS") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "PLACEMENT_BANNER_1", - "\"" + (System.getenv("PLACEMENT_BANNER_1") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "PLACEMENT_BANNER_2", - "\"" + (System.getenv("PLACEMENT_BANNER_2") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "PLACEMENT_INTERSTITIAL", - "\"" + (System.getenv("PLACEMENT_INTERSTITIAL") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "UNITY_APP_ID", - "\"" + (System.getenv("UNITY_APP_ID") ?: "empty") + "\"" - ) - buildConfigField( - "String", - "PLAY_CONSOLE_APP_RSA_KEY", - "\"" + (System.getenv("PLAY_CONSOLE_APP_RSA_KEY") ?: "empty") + "\"" - ) + val properties = Properties().apply { + load(project.rootProject.file("local.properties").inputStream()) + } + var value = "\"" + properties.getProperty("IAP_BUY_ME_COFFEE", "empty") + "\"" + buildConfigField("String", "IAP_BUY_ME_COFFEE", value) + value = "\"" + properties.getProperty("IAP_NO_ADS", "empty") + "\"" + buildConfigField("String", "IAP_NO_ADS", value) + value = "\"" + properties.getProperty("PLACEMENT_BANNER_1", "empty") + "\"" + buildConfigField("String", "PLACEMENT_BANNER_1", value) + value = "\"" + properties.getProperty("PLACEMENT_BANNER_1", "empty") + "\"" + buildConfigField("String", "PLACEMENT_BANNER_2", value) + value = "\"" + properties.getProperty("PLACEMENT_BANNER_2", "empty") + "\"" + buildConfigField("String", "PLACEMENT_INTERSTITIAL", value) + value = "\"" + properties.getProperty("PLACEMENT_INTERSTITIAL", "empty") + "\"" + buildConfigField("String", "PLACEMENT_BANNER_1", value) + value = "\"" + properties.getProperty("UNITY_APP_ID", "empty") + "\"" + buildConfigField("String", "UNITY_APP_ID", value) + value = "\"" + properties.getProperty("PLAY_CONSOLE_APP_RSA_KEY", "empty") + "\"" + buildConfigField("String", "PLAY_CONSOLE_APP_RSA_KEY", value) }