diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml deleted file mode 100644 index e0fcd75..0000000 --- a/.github/workflows/cd.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Android MBCGroup CI - -on: - push: - branches: - - develop - - main - pull_request: - branches: - - develop - - main - -jobs: - - build: - runs-on: ubuntu-latest - environment: ${{ github.ref_name }} - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: '17' - cache: 'gradle' - - - name: Set up Gradle cache - uses: actions/cache@v2 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Update local.properties - run: | - echo "SHARED_PREFERENCES_NAME=${{ secrets.SHARED_PREFERENCES_NAME }}" >> local.properties - echo "BASE_URL=${{ secrets.BASE_URL }}" >> local.properties - echo "BASE_URL_GQL=${{ secrets.BASE_URL_GQL }}" >> local.properties - echo "CLIENT_ID=${{ secrets.CLIENT_ID }}" >> local.properties - echo "CLIENT_SECRET=${{ secrets.CLIENT_SECRET }}" >> local.properties - echo "DEBUG_KEY_PASSWORD=${{ secrets.DEBUG_KEY_PASSWORD }}" >> local.properties - - - name: Execute validations - run: ./gradlew executeValidations - - - name: Build App - run: | - if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then - ./gradlew assembleRelease - else - ./gradlew assembleDebug - fi - - - name: Upload APK artifact - uses: actions/upload-artifact@v2 - with: - name: app-${{ github.ref == 'refs/heads/main' && 'release' || 'debug' }} - path: app/build/outputs/apk/${{ github.ref == 'refs/heads/main' && 'release' || 'debug' }}/app-${{ github.ref == 'refs/heads/main' && 'release' || 'debug' }}.apk diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000..5258cbc --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,122 @@ +name: Generate Debug + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + workflow_dispatch: + inputs: + buildType: + description: 'Build Type' + required: true + default: 'debug' + type: choice + options: + - debug + - release + groupTester: + description: 'Testers' + required: true + default: 'qa' + type: choice + options: + - all + - qa + - production + releaseNotes: + description: 'Release notes' + required: true + default: 'Update' + type: string + +jobs: + generation: + runs-on: ubuntu-latest + environment: ${{ github.ref_name }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + + - name: Set up Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Create Google Services File + run: cat /home/runner/work/MBCGroup/MBCGroup/app/google-services.json | base64 + - name: Add data Google Services File + env: + DATA: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: echo $DATA > /home/runner/work/MBCGroup/MBCGroup/app/google-services.json + - name: Configuration Local.properties + env: + SHARED_PREFERENCES_NAME: ${{ secrets.SHARED_PREFERENCES_NAME }} + BASE_URL: ${{ secrets.BASE_URL }} + BASE_URL_GQL: ${{ secrets.BASE_URL_GQL }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + run: | + echo "SHARED_PREFERENCES_NAME=$SHARED_PREFERENCES_NAME" >> local.properties + echo "BASE_URL=$BASE_URL" >> local.properties + echo "BASE_URL_GQL=$BASE_URL_GQL" >> local.properties + echo "CLIENT_ID=$CLIENT_ID" >> local.properties + echo "CLIENT_SECRET=$CLIENT_SECRET" >> local.properties + - name: Set RELEASE_NOTE + id: set_release_note + run: | + if [ -z "${{ inputs.releaseNotes }}" ]; then + RELEASE_NOTE=$(cat release_notes.txt) + else + RELEASE_NOTE="${{ inputs.releaseNotes }}" + fi + echo "RELEASE_NOTE_TEXT<> $GITHUB_ENV + echo $RELEASE_NOTE >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + - name: Set App ID + id: set_app_id + run: | + if [[ "${{ inputs.buildType || 'debug' }}" == "debug" ]]; then + echo "APP_ID=${{ secrets.APP_ID_DEBUG }}" >> $GITHUB_ENV + else + echo "APP_ID=${{ secrets.APP_ID_RELEASE }}" >> $GITHUB_ENV + fi + - name: Execute validations + run: ./gradlew executeValidations + - name: Build App Release + if: ${{ inputs.buildType || 'debug' }} != "debug" + run: ./gradlew assembleRelease + env: + DEBUG_KEY_PASSWORD: ${{ secrets.DEBUG_KEY_PASSWORD }} + - name: Build App Debug + if: ${{ inputs.buildType || 'debug' }} == "debug" + run: ./gradlew assembleDebug + env: + DEBUG_KEY_PASSWORD: ${{ secrets.DEBUG_KEY_PASSWORD }} + - name: Upload Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{ env.APP_ID }} + serviceCredentialsFileContent: ${{ secrets.FIREBASE_TOKEN }} + groups: ${{ inputs.groupTester || 'qa' }} + releaseNotes: ${{ env.RELEASE_NOTE_TEXT }} + file: app/build/outputs/apk/${{ inputs.buildType || 'debug' }}/app-${{ inputs.buildType || 'debug' }}.apk + debug: true + - name: Upload APK artifact + uses: actions/upload-artifact@v2 + with: + name: app-${{ inputs.buildType || 'debug' }} + path: app/build/outputs/apk/${{ inputs.buildType || 'debug' }}/app-${{ inputs.buildType || 'debug' }}.apk diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a05e50d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,122 @@ +name: Generate Release + +on: + workflow_dispatch: + inputs: + buildType: + description: 'Build Type' + required: true + default: 'release' + type: choice + options: + - debug + - release + groupTester: + description: 'Testers' + required: true + default: 'production' + type: choice + options: + - all + - qa + - production + releaseNotes: + description: 'Release notes' + required: true + default: 'Update' + type: string + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + generation: + runs-on: ubuntu-latest + environment: ${{ github.ref_name }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '17' + cache: 'gradle' + + - name: Set up Gradle cache + uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', '**/buildSrc/**/*.kt') }} + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + - name: Create Google Services File + run: cat /home/runner/work/MBCGroup/MBCGroup/app/google-services.json | base64 + - name: Add data Google Services File + env: + DATA: ${{ secrets.GOOGLE_SERVICES_JSON }} + run: echo $DATA > /home/runner/work/MBCGroup/MBCGroup/app/google-services.json + - name: Configuration Local.properties + env: + SHARED_PREFERENCES_NAME: ${{ secrets.SHARED_PREFERENCES_NAME }} + BASE_URL: ${{ secrets.BASE_URL }} + BASE_URL_GQL: ${{ secrets.BASE_URL_GQL }} + CLIENT_ID: ${{ secrets.CLIENT_ID }} + CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }} + run: | + echo "SHARED_PREFERENCES_NAME=$SHARED_PREFERENCES_NAME" >> local.properties + echo "BASE_URL=$BASE_URL" >> local.properties + echo "BASE_URL_GQL=$BASE_URL_GQL" >> local.properties + echo "CLIENT_ID=$CLIENT_ID" >> local.properties + echo "CLIENT_SECRET=$CLIENT_SECRET" >> local.properties + - name: Set RELEASE_NOTE + id: set_release_note + run: | + if [ -z "${{ inputs.releaseNotes }}" ]; then + RELEASE_NOTE=$(cat release_notes.txt) + else + RELEASE_NOTE="${{ inputs.releaseNotes }}" + fi + echo "RELEASE_NOTE_TEXT<> $GITHUB_ENV + echo $RELEASE_NOTE >> $GITHUB_ENV + echo "EOF" >> $GITHUB_ENV + - name: Set App ID + id: set_app_id + run: | + if [[ "${{ inputs.buildType || 'release' }}" == "release" ]]; then + echo "APP_ID=${{ secrets.APP_ID_RELEASE }}" >> $GITHUB_ENV + else + echo "APP_ID=${{ secrets.APP_ID_DEBUG }}" >> $GITHUB_ENV + fi + - name: Execute validations + run: ./gradlew executeValidations + - name: Build App Release + if: ${{ inputs.buildType || 'release' }} == "release" + run: ./gradlew assembleRelease + env: + DEBUG_KEY_PASSWORD: ${{ secrets.DEBUG_KEY_PASSWORD }} + - name: Build App Debug + if: ${{ inputs.buildType || 'release' }} != "release" + run: ./gradlew assembleDebug + env: + DEBUG_KEY_PASSWORD: ${{ secrets.DEBUG_KEY_PASSWORD }} + - name: Upload Firebase App Distribution + uses: wzieba/Firebase-Distribution-Github-Action@v1 + with: + appId: ${{ env.APP_ID }} + serviceCredentialsFileContent: ${{ secrets.FIREBASE_TOKEN }} + groups: ${{ inputs.groupTester || 'production' }} + releaseNotes: ${{ env.RELEASE_NOTE_TEXT }} + file: app/build/outputs/apk/${{ inputs.buildType || 'release' }}/app-${{ inputs.buildType || 'release' }}.apk + debug: true + - name: Upload APK artifact + uses: actions/upload-artifact@v2 + with: + name: app-${{ inputs.buildType || 'release' }} + path: app/build/outputs/apk/${{ inputs.buildType || 'release' }}/app-${{ inputs.buildType || 'release' }}.apk diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 4c6f2a1..3806616 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -1,14 +1,17 @@ +import com.android.build.gradle.internal.cxx.configure.gradleLocalProperties + plugins { id("com.android.application") id("org.jetbrains.kotlin.android") id("com.google.dagger.hilt.android") id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") id("com.apollographql.apollo3").version("3.7.3") + id("com.google.firebase.appdistribution") kotlin("kapt") + id("com.google.gms.google-services") } -private val localProperties = - com.android.build.gradle.internal.cxx.configure.gradleLocalProperties(rootDir) +private val localProperties = gradleLocalProperties(rootDir) fun getLocalProperty(key: String, defaultValue: String = ""): String = localProperties.getProperty(key, System.getenv(key) ?: defaultValue) @@ -58,6 +61,7 @@ android { } debug { signingConfig = signingConfigs.getByName("debug") + applicationIdSuffix = ".debug" isMinifyEnabled = true proguardFiles( getDefaultProguardFile("proguard-android-optimize.txt"), @@ -85,6 +89,10 @@ android { } } } +configure { + releaseNotesFile = "${projectDir}/../release_notes.txt" + groups = getLocalProperty("TESTERS_GROUP", "") +} dependencies { diff --git a/build.gradle.kts b/build.gradle.kts index d5104f0..bf77008 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,16 @@ plugins { id("com.github.ben-manes.versions") version "0.39.0" id("com.google.dagger.hilt.android") version "2.48" apply false id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin") version "2.0.1" apply false + } +buildscript { + dependencies { + classpath("com.google.gms:google-services:4.4.0") + classpath("com.android.tools.build:gradle:8.1.0") + classpath("com.google.firebase:firebase-appdistribution-gradle:4.0.1") + } +} + allprojects { apply(plugin = "org.jmailen.kotlinter") apply(plugin = "io.gitlab.arturbosch.detekt") diff --git a/release_notes.txt b/release_notes.txt new file mode 100644 index 0000000..1895c8a --- /dev/null +++ b/release_notes.txt @@ -0,0 +1,3 @@ +SPRINT 1: +- SM-1324 Android - Ocultar pestaƱas sin informaciĆ³n en PDP +- SM-1358 Android - Habilitar Mi Cuenta en Ecuador \ No newline at end of file