Skip to content

Commit

Permalink
[CHORE] Build official apps on CI (#2701)
Browse files Browse the repository at this point in the history
* Duplicated target and changed Bridging Header

* Display name

* Unnecessary dumb swift file removed

* Buildable name

* Reorder Info.plist

* Rename Official target's bundle id

* Ignore .mobileprovision

* Fix provisioning of official app

* Starting signing

* stash fastfile

* starting official ci iOS

* Uncomment Fastfile keychain

* Fix CI config

* allowProvisioningUpdates

* Changing AppIcon and Splash Screen

* Remove unnecessary folder inside of Images.xcassets

* Reorder notificationservice and shareextension plists

* Fix signing

* Manual signing style for official

* Split official signing

* Update project provisioning

* Use ENV as profile

* Output match

* Keys

* TestFlight refactor

* Setting up android

* android-official-play-build job

* Start removing unnecessary fastlane tasks on Android

* Trying to refactor Android jobs

* android-env

* Remove foss build for now

* Fork

* Fix if conditions

* Fix push

* ios-build command

* Rename Android builds

* Upload dSYMs

* Refactoring workflow

* Reorder upload-to-testflight

* upload-to-google-play-beta command

* Fix ci

* Fix android fork build

* Fix keystore

* Fix options on fastlane android

* Fix keystore

* Check isOfficial on iOS

* Check isOfficial on db

* Remove unused imports

* Database names on Android

* Tag fix

* Minor fixes

* Set IS_OFFICIAL on CI

* Fix detox

* follow review suggestions

Co-authored-by: Djorkaeff Alexandre <djorkaeff.unb@gmail.com>
  • Loading branch information
diegolmello and djorkaeffalexandre authored Dec 14, 2020
1 parent c9c8bde commit cd76dd9
Show file tree
Hide file tree
Showing 135 changed files with 1,376 additions and 463 deletions.
448 changes: 249 additions & 199 deletions .circleci/config.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ DerivedData
*.ipa
*.xcuserstate
project.xcworkspace
*.mobileprovision

# Android/IntelliJ
#
Expand Down
34 changes: 25 additions & 9 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString().toLowerCase()
def isPlay = !taskRequests.contains("foss")
def isFoss = taskRequests.contains("foss")

apply plugin: "com.android.application"
apply plugin: 'kotlin-android'

if (isPlay) {
if (!isFoss) {
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'com.bugsnag.android.gradle'
}
Expand Down Expand Up @@ -146,7 +146,7 @@ android {
versionCode VERSIONCODE as Integer
versionName "4.13.0"
vectorDrawables.useSupportLibrary = true
if (isPlay) {
if (!isFoss) {
manifestPlaceholders = [BugsnagAPIKey: BugsnagAPIKey as String]
missingDimensionStrategy "RNNotifications.reactNativeVersion", "reactNative60" // See note below!
}
Expand Down Expand Up @@ -176,7 +176,7 @@ android {
minifyEnabled enableProguardInReleaseBuilds
setProguardFiles([getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'])
signingConfig signingConfigs.release
if (isPlay) {
if (!isFoss) {
firebaseCrashlytics {
nativeSymbolUploadEnabled true
}
Expand All @@ -193,10 +193,17 @@ android {

// applicationVariants are e.g. debug, release

flavorDimensions "type"
flavorDimensions "app", "type"
productFlavors {
official {
dimension = "app"
buildConfigField "boolean", "IS_OFFICIAL", "true"
}
experimental {
dimension = "app"
buildConfigField "boolean", "IS_OFFICIAL", "false"
}
foss {
applicationId APPLICATION_ID
dimension = "type"
buildConfigField "boolean", "FDROID_BUILD", "true"
}
Expand All @@ -206,11 +213,20 @@ android {
}
}
sourceSets {
playDebug {
// TODO: refactor making sure notifications are working properly both on debug and release
experimentalPlayDebug {
java.srcDirs = ['src/main/java', 'src/play/java']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
experimentalPlayRelease {
java.srcDirs = ['src/main/java', 'src/play/java']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
officialPlayDebug {
java.srcDirs = ['src/main/java', 'src/play/java']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
playRelease {
officialPlayRelease {
java.srcDirs = ['src/main/java', 'src/play/java']
manifest.srcFile 'src/play/AndroidManifest.xml'
}
Expand Down Expand Up @@ -287,6 +303,6 @@ task copyDownloadableDepsToLibs(type: Copy) {
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
if (isPlay) {
if (!isFoss) {
apply plugin: 'com.google.gms.google-services'
}
83 changes: 83 additions & 0 deletions android/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"project_info": {
"project_number": "115198584049",
"firebase_url": "https://rocketchat-reactnative-test.firebaseio.com",
"project_id": "rocketchat-reactnative-test",
"storage_bucket": "rocketchat-reactnative-test.appspot.com"
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "1:115198584049:android:a79216ae48935d2c9ab550",
"android_client_info": {
"package_name": "chat.rocket.android"
}
},
"oauth_client": [
{
"client_id": "115198584049-ack609b1338b827fta26s9rd2ab1aad5.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAWwowhAfACHBw3YxmDOXY3QyakgjhJLqc"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "115198584049-ack609b1338b827fta26s9rd2ab1aad5.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "115198584049-0efgfvm0oh9ap55g7epmqnjm27mq3j4e.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "chat.rocket.reactnative"
}
}
]
}
}
},
{
"client_info": {
"mobilesdk_app_id": "1:115198584049:android:8be27b1f7c42a2ed",
"android_client_info": {
"package_name": "chat.rocket.reactnative"
}
},
"oauth_client": [
{
"client_id": "115198584049-ack609b1338b827fta26s9rd2ab1aad5.apps.googleusercontent.com",
"client_type": 3
}
],
"api_key": [
{
"current_key": "AIzaSyAWwowhAfACHBw3YxmDOXY3QyakgjhJLqc"
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": [
{
"client_id": "115198584049-ack609b1338b827fta26s9rd2ab1aad5.apps.googleusercontent.com",
"client_type": 3
},
{
"client_id": "115198584049-0efgfvm0oh9ap55g7epmqnjm27mq3j4e.apps.googleusercontent.com",
"client_type": 2,
"ios_info": {
"bundle_id": "chat.rocket.reactnative"
}
}
]
}
}
}
],
"configuration_version": "1"
}
File renamed without changes
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions android/app/src/foss/res/values-night/colors.xml

This file was deleted.

28 changes: 0 additions & 28 deletions android/app/src/foss/res/values/styles.xml

This file was deleted.

3 changes: 1 addition & 2 deletions android/app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="splashBackground" type="color">#000000</item>
<item name="notification_text" type="color">#1D74F5</item>
</resources>
</resources>
File renamed without changes
File renamed without changes.
File renamed without changes.
40 changes: 0 additions & 40 deletions android/app/src/play/google-services.json

This file was deleted.

50 changes: 30 additions & 20 deletions android/app/src/play/java/chat/rocket/reactnative/Encryption.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package chat.rocket.reactnative;

import android.util.Log;
import android.util.Base64;
import android.database.Cursor;
import android.util.Base64;
import android.util.Log;

import com.pedrouid.crypto.RSA;
import com.pedrouid.crypto.RCTAes;
import com.pedrouid.crypto.RCTRsaUtils;
import com.pedrouid.crypto.Util;

import com.google.gson.Gson;

import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;

import com.facebook.react.bridge.WritableMap;
import com.google.gson.Gson;
import com.nozbe.watermelondb.Database;
import com.pedrouid.crypto.RCTAes;
import com.pedrouid.crypto.RCTRsaUtils;
import com.pedrouid.crypto.RSA;
import com.pedrouid.crypto.Util;

import java.util.Arrays;
import java.lang.reflect.Field;
import java.security.SecureRandom;
import java.util.Arrays;

class Message {
String _id;
Expand Down Expand Up @@ -69,8 +63,24 @@ class Encryption {
public static Encryption shared = new Encryption();
private ReactApplicationContext reactContext;

public Room readRoom(final Ejson ejson) {
Database database = new Database(ejson.serverURL().replace("https://", "") + "-experimental.db", reactContext);
public Room readRoom(final Ejson ejson) throws NoSuchFieldException {
int resId = reactContext.getResources().getIdentifier("rn_config_reader_custom_package", "string", reactContext.getPackageName());
String className = reactContext.getString(resId);
Class clazz = null;
Boolean isOfficial = false;
try {
clazz = Class.forName(className + ".BuildConfig");
Field IS_OFFICIAL = clazz.getField("IS_OFFICIAL");
isOfficial = (Boolean) IS_OFFICIAL.get(null);
} catch (ClassNotFoundException | IllegalAccessException e) {
e.printStackTrace();
}
String dbName = ejson.serverURL().replace("https://", "");
if (!isOfficial) {
dbName += "-experimental";
}
dbName += ".db";
Database database = new Database(dbName, reactContext);
String[] query = {ejson.rid};
Cursor cursor = database.rawQuery("select * from subscriptions where id == ? limit 1", query);

Expand Down Expand Up @@ -152,7 +162,7 @@ public String decryptMessage(final Ejson ejson, final ReactApplicationContext re

return m.text;
} catch (Exception e) {
Log.d("[ROCKETCHAT][ENCRYPTION]", Log.getStackTraceString(e));
Log.d("[ROCKETCHAT][E2E]", Log.getStackTraceString(e));
}

return null;
Expand Down Expand Up @@ -182,7 +192,7 @@ public String encryptMessage(final String message, final String id, final Ejson

return keyId + Base64.encodeToString(concat(bytes, data), Base64.NO_WRAP);
} catch (Exception e) {
Log.d("[ROCKETCHAT][ENCRYPTION]", Log.getStackTraceString(e));
Log.d("[ROCKETCHAT][E2E]", Log.getStackTraceString(e));
}

return message;
Expand Down
34 changes: 14 additions & 20 deletions android/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,20 @@
default_platform(:android)

platform :android do
desc "Play build for development"
lane :playBuild do
gradle(task: "assemblePlayDebug")
end

desc "Foss build for release"
lane :fossRelease do
gradle(task: "assembleFossRelease")
end

desc "Play build for release"
lane :playRelease do
gradle(task: "bundlePlayRelease")
end

desc "Upload App to Play Store Internal"
lane :beta do
upload_to_play_store(
track: 'internal',
aab: 'android/app/build/outputs/bundle/playRelease/app-play-release.aab'
)
lane :beta do |options|
if options[:official]
upload_to_play_store(
package_name: 'chat.rocket.android',
track: 'internal',
aab: 'android/app/build/outputs/bundle/officialPlayRelease/app-official-play-release.aab'
)
else
upload_to_play_store(
package_name: 'chat.rocket.reactnative',
track: 'internal',
aab: 'android/app/build/outputs/bundle/experimentalPlayRelease/app-experimental-play-release.aab'
)
end
end
end
2 changes: 2 additions & 0 deletions app/constants/environment.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import RNConfigReader from 'react-native-config-reader';

export const isFDroidBuild = RNConfigReader.FDROID_BUILD;

export const isOfficial = RNConfigReader.IS_OFFICIAL;
Loading

0 comments on commit cd76dd9

Please sign in to comment.