Skip to content

Commit 4ed24b5

Browse files
authored
Merge pull request #6478 from vector-im/feature/bma/nightly
Nightly build published on Firebase
2 parents 6b403ec + 95f4d88 commit 4ed24b5

File tree

12 files changed

+214
-2
lines changed

12 files changed

+214
-2
lines changed

.github/workflows/nightly.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Build and release nightly APK
2+
3+
on:
4+
schedule:
5+
# Every nights at 4
6+
- cron: "0 4 * * *"
7+
8+
env:
9+
CI_GRADLE_ARG_PROPERTIES: >
10+
-Porg.gradle.jvmargs=-Xmx4g
11+
-Porg.gradle.parallel=false
12+
--no-daemon
13+
14+
jobs:
15+
nightly:
16+
name: Build and publish nightly Gplay APK to Firebase
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v3
20+
- name: Set up Python 3.8
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: 3.8
24+
- uses: actions/cache@v3
25+
with:
26+
path: |
27+
~/.gradle/caches
28+
~/.gradle/wrapper
29+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
30+
restore-keys: |
31+
${{ runner.os }}-gradle-
32+
- name: Install towncrier
33+
run: |
34+
python3 -m pip install towncrier
35+
- name: Prepare changelog file
36+
run: |
37+
mv towncrier.toml towncrier.toml.bak
38+
sed 's/CHANGES\.md/CHANGES_NIGHTLY\.md/' towncrier.toml.bak > towncrier.toml
39+
rm towncrier.toml.bak
40+
yes n | towncrier --version nightly
41+
- name: Build and upload Gplay Nightly APK
42+
run: |
43+
./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES --stacktrace
44+
env:
45+
ELEMENT_ANDROID_NIGHTLY_KEYID: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYID }}
46+
ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD }}
47+
ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD }}
48+
FIREBASE_TOKEN: ${{ secrets.ELEMENT_ANDROID_NIGHTLY_FIREBASE_TOKEN }}

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ buildscript {
2424
classpath libs.gradle.gradlePlugin
2525
classpath libs.gradle.kotlinPlugin
2626
classpath libs.gradle.hiltPlugin
27+
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.2'
2728
classpath 'com.google.gms:google-services:4.3.13'
2829
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.4.0.2513'
2930
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'

changelog.d/6478.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nightly build publication on Firebase

docs/nightly_build.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Nightly builds
2+
3+
<!--- TOC -->
4+
5+
* [Configuration](#configuration)
6+
* [How to register to get nightly build](#how-to-register-to-get-nightly-build)
7+
* [Build nightly manually](#build-nightly-manually)
8+
9+
<!--- END -->
10+
11+
## Configuration
12+
13+
The nightly build will contain what's on develop, in release mode, for Gplay variant. It is signed using a dedicated signature, and has a dedicated appId (`im.vector.app.nightly`), so it can be installed along with the production version of Element Android. The only other difference compared to Element Android is a different app icon background. We do not want to change the app name since it will also affect some strings in the app, and we do want to do that.
14+
15+
Nightly builds are built and released to Firebase every days, and automatically.
16+
17+
This is recommended to exclusively use this app, with your main account, instead of Element Android, and fallback to Element Android just in case of regression, to discover as soon as possible any regression, and report it to the team. To avoid double notification, you may want to disable the notification from the Element Android production version. Just open Element Android, navigate to `Settings/Notifications` and uncheck `Enable notifications for this session`.
18+
19+
*Note:* Due to a limitation of Firebase, the nightly build is the universal build, which means that the size of the APK is a bit bigger, but this should not have any other side effect.
20+
21+
## How to register to get nightly build
22+
23+
Provide your email to the Android team, who will add it to the list "External testers" on Firebase. You will then receive an invite on the provided email.
24+
25+
Follow the instructions on the email to install the latest nightly build. This is not clear yet if new nightly build will be automatically installed or not.
26+
27+
## Build nightly manually
28+
29+
Nightly build can be built manually from your computer. You will need to retrieved some secrets from Passbolt and add them to your file `~/.gradle/gradle.properties`:
30+
31+
```
32+
signing.element.nightly.storePassword=VALUE_FROM_PASSBOLT
33+
signing.element.nightly.keyId=VALUE_FROM_PASSBOLT
34+
signing.element.nightly.keyPassword=VALUE_FROM_PASSBOLT
35+
```
36+
37+
You will also need to add the environment variable `FIREBASE_TOKEN`:
38+
39+
```sh
40+
export FIREBASE_TOKEN=VALUE_FROM_PASSBOLT
41+
```
42+
43+
Then you can run the following commands (which are also used in the file for [the GitHub action](../.github/workflows/nightly.yml)):
44+
45+
```sh
46+
git checkout develop
47+
mv towncrier.toml towncrier.toml.bak
48+
sed 's/CHANGES\.md/CHANGES_NIGHTLY\.md/' towncrier.toml.bak > towncrier.toml
49+
rm towncrier.toml.bak
50+
yes n | towncrier --version nightly
51+
./gradlew assembleGplayNightly appDistributionUploadGplayNightly $CI_GRADLE_ARG_PROPERTIES --stacktrace
52+
```
53+
54+
Then you can reset the change on the codebase.

gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,8 @@ signing.element.storePath=pathTo.keystore
3232
signing.element.storePassword=Secret
3333
signing.element.keyId=Secret
3434
signing.element.keyPassword=Secret
35+
36+
# Dummy values for signing secrets / nightly
37+
signing.element.nightly.storePassword=Secret
38+
signing.element.nightly.keyId=Secret
39+
signing.element.nightly.keyPassword=Secret

vector/build.gradle

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import com.android.build.OutputFile
22

33
apply plugin: 'com.android.application'
4+
apply plugin: 'com.google.firebase.appdistribution'
45
apply plugin: 'com.google.android.gms.oss-licenses-plugin'
56
apply plugin: 'kotlin-android'
67
apply plugin: 'kotlin-parcelize'
@@ -228,6 +229,12 @@ android {
228229
storeFile file('./signature/debug.keystore')
229230
storePassword 'android'
230231
}
232+
nightly {
233+
keyAlias System.env.ELEMENT_ANDROID_NIGHTLY_KEYID ?: project.property("signing.element.nightly.keyId")
234+
keyPassword System.env.ELEMENT_ANDROID_NIGHTLY_KEYPASSWORD ?: project.property("signing.element.nightly.keyPassword")
235+
storeFile file('./signature/nightly.keystore')
236+
storePassword System.env.ELEMENT_ANDROID_NIGHTLY_STOREPASSWORD ?: project.property("signing.element.nightly.storePassword")
237+
}
231238
release {
232239
keyAlias project.property("signing.element.keyId")
233240
keyPassword project.property("signing.element.keyPassword")
@@ -240,6 +247,7 @@ android {
240247
debug {
241248
applicationIdSuffix ".debug"
242249
resValue "string", "app_name", "Element dbg"
250+
resValue "color", "launcher_background", "#0DBD8B"
243251

244252
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
245253
// Set to true if you want to enable strict mode in debug
@@ -254,10 +262,12 @@ android {
254262

255263
release {
256264
resValue "string", "app_name", "Element"
265+
resValue "color", "launcher_background", "#0DBD8B"
257266

258267
buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false"
259268
buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false"
260269

270+
// When updating this block, please also update the same block in the `nightly` buildType below
261271
postprocessing {
262272
removeUnusedCode true
263273
removeUnusedResources true
@@ -268,6 +278,40 @@ android {
268278
}
269279
// signingConfig signingConfigs.release
270280
}
281+
282+
nightly {
283+
applicationIdSuffix ".nightly"
284+
versionNameSuffix "-nightly"
285+
286+
initWith release
287+
// Just override the background color of the launcher icon for the nightly build.
288+
resValue "color", "launcher_background", "#07007E"
289+
290+
// We need to copy paste this block, this is not done automatically by `initWith release`
291+
postprocessing {
292+
removeUnusedCode true
293+
removeUnusedResources true
294+
// We do not activate obfuscation as it makes it hard then to read crash reports, and it's a bit useless on an open source project :)
295+
obfuscate false
296+
optimizeCode true
297+
proguardFiles 'proguard-rules.pro'
298+
}
299+
matchingFallbacks = ['release']
300+
signingConfig signingConfigs.nightly
301+
firebaseAppDistribution {
302+
artifactType = "APK"
303+
// We upload the universal APK to fix this error:
304+
// "App Distribution found more than 1 output file for this variant.
305+
// Please contact [email protected] for help using APK splits with App Distribution."
306+
artifactPath = "$rootDir/vector/build/outputs/apk/gplay/nightly/vector-gplay-universal-nightly.apk"
307+
// This file will be generated by the GitHub action
308+
releaseNotesFile = "CHANGES_NIGHTLY.md"
309+
groups = "external-testers"
310+
// This should not be required, but if I do not add the appId, I get this error:
311+
// "App Distribution halted because it had a problem uploading the APK: [404] Requested entity was not found."
312+
appId = "1:912726360885:android:efd8545af52a9f9300427c"
313+
}
314+
}
271315
}
272316

273317
flavorDimensions "store"
@@ -334,6 +378,10 @@ android {
334378
test {
335379
java.srcDirs += "src/sharedTest/java"
336380
}
381+
// Add sourceSets for `release` version when building `nightly`
382+
nightly {
383+
java.srcDirs += "src/release/java"
384+
}
337385
}
338386

339387
buildFeatures {

vector/signature/nightly.keystore

2.17 KB
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"project_info": {
3+
"project_number": "912726360885",
4+
"firebase_url": "https://vector-alpha.firebaseio.com",
5+
"project_id": "vector-alpha",
6+
"storage_bucket": "vector-alpha.appspot.com"
7+
},
8+
"client": [
9+
{
10+
"client_info": {
11+
"mobilesdk_app_id": "1:912726360885:android:4ef8f3a0021e774d",
12+
"android_client_info": {
13+
"package_name": "im.vector.app.nightly"
14+
}
15+
},
16+
"oauth_client": [
17+
{
18+
"client_id": "912726360885-e87n3jva9uoj4vbidvijq78ebg02asv2.apps.googleusercontent.com",
19+
"client_type": 3
20+
}
21+
],
22+
"api_key": [
23+
{
24+
"current_key": "AIzaSyAFZX8IhIfgzdOZvxDP_ISO5WYoU7jmQ5c"
25+
}
26+
],
27+
"services": {
28+
"appinvite_service": {
29+
"other_platform_oauth_client": [
30+
{
31+
"client_id": "912726360885-rsae0i66rgqt6ivnudu1pv4tksg9i8b2.apps.googleusercontent.com",
32+
"client_type": 3
33+
}
34+
]
35+
}
36+
}
37+
}
38+
],
39+
"configuration_version": "1"
40+
}

vector/src/main/java/im/vector/app/features/rageshake/BugReporter.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ class BugReporter @Inject constructor(
346346
// Special for Element
347347
builder.addFormDataPart("label", "[Element]")
348348

349+
// Possible values for BuildConfig.BUILD_TYPE: "debug", "nightly", "release".
350+
builder.addFormDataPart("label", BuildConfig.BUILD_TYPE)
351+
349352
when (reportType) {
350353
ReportType.BUG_REPORT -> {
351354
/* nop */

vector/src/main/res/drawable/ic_launcher_background.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
android:viewportHeight="108">
66
<path
77
android:pathData="m0,0h108v108h-108z"
8-
android:fillColor="#0DBD8B"
8+
android:fillColor="@color/launcher_background"
99
android:fillType="evenOdd"/>
1010
</vector>

0 commit comments

Comments
 (0)