diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 7688e7d..94dd6ab 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -41,9 +41,6 @@ jobs: - name: Build with Gradle run: ./gradlew build env: + PROD_SAMPLE_PROJECT_ID: ${{ secrets.PROD_SAMPLE_PROJECT_ID }} PROD_MAPPING_UPLOAD_CLIENT_ID: ${{ secrets.PROD_MAPPING_UPLOAD_CLIENT_ID }} PROD_MAPPING_UPLOAD_CLIENT_SECRET: ${{ secrets.PROD_MAPPING_UPLOAD_CLIENT_SECRET }} - - # Optional Step: Run your tests - - name: Run tests - run: ./gradlew test diff --git a/CSSampleApp/build.gradle b/CSSampleApp/build.gradle index a31950f..fb6a89c 100644 --- a/CSSampleApp/build.gradle +++ b/CSSampleApp/build.gradle @@ -8,7 +8,6 @@ plugins { android { compileSdk 35 - def csProjectId = 5671 defaultConfig { applicationId "com.example.androidsampleapp" minSdk 21 @@ -25,23 +24,17 @@ android { release { minifyEnabled true proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + // Set credentials from different source, fallback on Github CI --> see android-ci.yml + def localProperties = getLocalProperties() errorAnalysisCrash { uploadCredentials { - projectId = csProjectId - clientId = System.getenv("PROD_MAPPING_UPLOAD_CLIENT_ID") ?: "" - clientSecret = System.getenv("PROD_MAPPING_UPLOAD_CLIENT_SECRET") ?: "" - } - } - } - - minify { - minifyEnabled true - proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' - signingConfig signingConfigs.debug - errorAnalysisCrash { - uploadCredentials { - projectId = csProjectId - clientId = System.getenv("PROD_MAPPING_UPLOAD_CLIENT_ID") ?: "" + // from gradle.properties + projectId = project.findProperty("PROD_SAMPLE_PROJECT_ID")?.toInteger() ?: + System.getenv("PROD_SAMPLE_PROJECT_ID") + // from local.properties + clientId = localProperties.getProperty("PROD_MAPPING_UPLOAD_CLIENT_ID", "") ?: + System.getenv("PROD_MAPPING_UPLOAD_CLIENT_ID") + // from environment variable, is the same than Github CI here clientSecret = System.getenv("PROD_MAPPING_UPLOAD_CLIENT_SECRET") ?: "" } } @@ -98,3 +91,13 @@ dependencies { androidTestImplementation 'androidx.test.ext:junit:1.2.1' androidTestImplementation 'androidx.test.espresso:espresso-core:3.6.1' } + +def getLocalProperties() { + def localProperties = new Properties() + def localPropertiesFile = rootProject.file("local.properties") + if (localPropertiesFile.exists()) { + localProperties.load(new FileInputStream(localPropertiesFile)) + return localProperties + } + return null +} \ No newline at end of file