diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml new file mode 100644 index 0000000000..3d34d74184 --- /dev/null +++ b/.github/workflows/nightly.yml @@ -0,0 +1,25 @@ +name: Build and release nightly APK + +on: + schedule: + # Every nights at 4 + - cron: "0 4 * * *" + +env: + GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false + CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon + +jobs: + nightly: + name: Build and publish nightly APK to Firebase + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build and upload Nightly APK + run: | + ./gradlew assembleNightly appDistributionUploadNightly $CI_GRADLE_ARG_PROPERTIES + env: + ELEMENT_ANDROID_NIGHTLY_KEYID: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYID }} + ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD }} + ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD }} + FIREBASE_TOKEN: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_FIREBASE_TOKEN }} diff --git a/app/build.gradle b/app/build.gradle index b62cc43e8a..d2c34c895d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,6 +2,7 @@ plugins { id 'com.android.application' id 'org.jetbrains.kotlin.android' id 'com.google.devtools.ksp' version '1.7.20-1.0.7' + id 'com.google.firebase.appdistribution' version '3.0.2' } android { @@ -20,6 +21,21 @@ android { } } + signingConfigs { + debug { + keyAlias 'androiddebugkey' + keyPassword 'android' + storeFile file('./signature/debug.keystore') + storePassword 'android' + } + nightly { + keyAlias System.env.ELEMENT_ANDROID_NIGHTLY_KEYID ?: project.property("signing.element.nightly.keyId") + keyPassword System.env.ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD ?: project.property("signing.element.nightly.keyPassword") + storeFile file('./signature/nightly.keystore') + storePassword System.env.ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD ?: project.property("signing.element.nightly.storePassword") + } + } + buildTypes { debug { resValue "string", "app_name", "ElementX dbg" @@ -33,6 +49,24 @@ android { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } + + nightly { + initWith release + applicationIdSuffix ".nightly" + versionNameSuffix "-nightly" + resValue "string", "app_name", "ElementX nightly" + matchingFallbacks = ['release'] + signingConfig signingConfigs.nightly + firebaseAppDistribution { + artifactType = "APK" + // releaseNotesFile = TODO + groups = "external-testers" + // This should not be required, but if I do not add the appId, I get this error: + // "App Distribution halted because it had a problem uploading the APK: [404] Requested entity was not found." + appId = "1:912726360885:android:e17435e0beb0303000427c" + } + } + } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -60,15 +94,6 @@ android { } } } - - signingConfigs { - debug { - keyAlias 'androiddebugkey' - keyPassword 'android' - storeFile file('./signature/debug.keystore') - storePassword 'android' - } - } } dependencies { diff --git a/app/signature/nightly.keystore b/app/signature/nightly.keystore new file mode 100644 index 0000000000..a0e9ba413b Binary files /dev/null and b/app/signature/nightly.keystore differ diff --git a/app/src/nightly/google-services.json b/app/src/nightly/google-services.json new file mode 100644 index 0000000000..09bfee08f7 --- /dev/null +++ b/app/src/nightly/google-services.json @@ -0,0 +1,40 @@ +{ + "project_info": { + "project_number": "912726360885", + "firebase_url": "https://vector-alpha.firebaseio.com", + "project_id": "vector-alpha", + "storage_bucket": "vector-alpha.appspot.com" + }, + "client": [ + { + "client_info": { + "mobilesdk_app_id": "1:912726360885:android:e17435e0beb0303000427c", + "android_client_info": { + "package_name": "io.element.android.x.nightly" + } + }, + "oauth_client": [ + { + "client_id": "912726360885-e87n3jva9uoj4vbidvijq78ebg02asv2.apps.googleusercontent.com", + "client_type": 3 + } + ], + "api_key": [ + { + "current_key": "AIzaSyAFZX8IhIfgzdOZvxDP_ISO5WYoU7jmQ5c" + } + ], + "services": { + "appinvite_service": { + "other_platform_oauth_client": [ + { + "client_id": "912726360885-e87n3jva9uoj4vbidvijq78ebg02asv2.apps.googleusercontent.com", + "client_type": 3 + } + ] + } + } + } + ], + "configuration_version": "1" +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index cd0519bb2a..c4b415660b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -20,4 +20,9 @@ kotlin.code.style=official # Enables namespacing of each library's R class so that its R class includes only the # resources declared in the library itself and none from the library's dependencies, # thereby reducing the size of the R class for that library -android.nonTransitiveRClass=true \ No newline at end of file +android.nonTransitiveRClass=true + +# Dummy values for signing secrets / nightly +signing.element.nightly.storePassword=Secret +signing.element.nightly.keyId=Secret +signing.element.nightly.keyPassword=Secret \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index fcb7bba663..9e65a56147 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,7 @@ [versions] # Project android_gradle_plugin = "7.3.1" +firebase_gradle_plugin = "3.0.2" kotlin = "1.7.20" # AndroidX @@ -41,6 +42,7 @@ serialization-json = "1.4.1" [libraries] # Project android_gradle_plugin = { module = "com.android.tools.build:gradle", version.ref = "android_gradle_plugin" } +firebase_gradle_plugin = { module = "com.google.firebase:firebase-appdistribution-gradle", version.ref = "firebase_gradle_plugin" } kotlin_gradle_plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" } # AndroidX diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts index dcb444f0fd..ecd4aabe6a 100644 --- a/plugins/build.gradle.kts +++ b/plugins/build.gradle.kts @@ -11,4 +11,5 @@ repositories { dependencies { implementation(libs.android.gradle.plugin) implementation(libs.kotlin.gradle.plugin) + implementation(libs.firebase.gradle.plugin) }