From ed753130e1bc08428ca8ef8a02ecb2f6c6bbbb2f Mon Sep 17 00:00:00 2001
From: Rodrigo Nascimento <rodrigoknascimento@gmail.com>
Date: Tue, 7 Nov 2017 14:58:33 -0200
Subject: [PATCH] Set CircleCI build number as app build number

---
 .circleci/config.yml                       | 2 ++
 android/app/build.gradle                   | 2 +-
 ios/RocketChatRN-tvOS/Info.plist           | 2 +-
 ios/RocketChatRN-tvOSTests/Info.plist      | 2 +-
 ios/RocketChatRN.xcodeproj/project.pbxproj | 4 ++--
 ios/RocketChatRN/Info.plist                | 2 +-
 ios/RocketChatRNTests/Info.plist           | 2 +-
 7 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 900ae4cf7..a1448d038 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -83,6 +83,7 @@ jobs:
             echo -e "KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties
             echo -e "KEY_ALIAS=$KEY_ALIAS" >> ./gradle.properties
             echo -e "KEY_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties
+            echo -e "VERSIONCODE=$CIRCLE_BUILD_NUM" >> ./gradle.properties
 
             ./gradlew assembleRelease
 
@@ -148,6 +149,7 @@ jobs:
           no_output_timeout: 1200
           command: |
             cd ios
+            agvtool new-version -all $CIRCLE_BUILD_NUM
             fastlane ios build
 
       - store_artifacts:
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 84a31c924..986dcfde2 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -97,7 +97,7 @@ android {
         applicationId "chat.rocket.reactnative"
         minSdkVersion 16
         targetSdkVersion 22
-        versionCode 2
+        versionCode VERSIONCODE as Integer
         versionName "1.1"
         ndk {
             abiFilters "armeabi-v7a", "x86"
diff --git a/ios/RocketChatRN-tvOS/Info.plist b/ios/RocketChatRN-tvOS/Info.plist
index ecbd496be..3f282f972 100644
--- a/ios/RocketChatRN-tvOS/Info.plist
+++ b/ios/RocketChatRN-tvOS/Info.plist
@@ -19,7 +19,7 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>100</string>
 	<key>LSRequiresIPhoneOS</key>
 	<true/>
 	<key>NSAppTransportSecurity</key>
diff --git a/ios/RocketChatRN-tvOSTests/Info.plist b/ios/RocketChatRN-tvOSTests/Info.plist
index 886825ccc..c464f05ab 100644
--- a/ios/RocketChatRN-tvOSTests/Info.plist
+++ b/ios/RocketChatRN-tvOSTests/Info.plist
@@ -19,6 +19,6 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>100</string>
 </dict>
 </plist>
diff --git a/ios/RocketChatRN.xcodeproj/project.pbxproj b/ios/RocketChatRN.xcodeproj/project.pbxproj
index 8a33f326c..7ec2a0d47 100644
--- a/ios/RocketChatRN.xcodeproj/project.pbxproj
+++ b/ios/RocketChatRN.xcodeproj/project.pbxproj
@@ -1380,7 +1380,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
 				CODE_SIGN_STYLE = Manual;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 100;
 				DEAD_CODE_STRIPPING = NO;
 				DEVELOPMENT_TEAM = S6UPZG7ZR3;
 				HEADER_SEARCH_PATHS = (
@@ -1415,7 +1415,7 @@
 				ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
 				"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
 				CODE_SIGN_STYLE = Manual;
-				CURRENT_PROJECT_VERSION = 1;
+				CURRENT_PROJECT_VERSION = 100;
 				DEVELOPMENT_TEAM = S6UPZG7ZR3;
 				HEADER_SEARCH_PATHS = (
 					"$(inherited)",
diff --git a/ios/RocketChatRN/Info.plist b/ios/RocketChatRN/Info.plist
index 49a13c119..1dbf4f5bf 100644
--- a/ios/RocketChatRN/Info.plist
+++ b/ios/RocketChatRN/Info.plist
@@ -21,7 +21,7 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>4</string>
+	<string>100</string>
 	<key>ITSAppUsesNonExemptEncryption</key>
 	<false/>
 	<key>LSRequiresIPhoneOS</key>
diff --git a/ios/RocketChatRNTests/Info.plist b/ios/RocketChatRNTests/Info.plist
index 886825ccc..c464f05ab 100644
--- a/ios/RocketChatRNTests/Info.plist
+++ b/ios/RocketChatRNTests/Info.plist
@@ -19,6 +19,6 @@
 	<key>CFBundleSignature</key>
 	<string>????</string>
 	<key>CFBundleVersion</key>
-	<string>1</string>
+	<string>100</string>
 </dict>
 </plist>
-- 
GitLab