Skip to content
This repository has been archived by the owner on Oct 5, 2022. It is now read-only.

Commit

Permalink
Automate build and deploy for both Android and iOS (#65)
Browse files Browse the repository at this point in the history
  • Loading branch information
martincarrera committed Apr 12, 2019
1 parent 35632f6 commit 91e64fb
Show file tree
Hide file tree
Showing 42 changed files with 728 additions and 494 deletions.
15 changes: 11 additions & 4 deletions .gitignore
Expand Up @@ -41,23 +41,30 @@ buck-out/
\.buckd/
*.keystore

## Obj-C/Swift specific
*.dSYM.zip
*.dSYM

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots
**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots

# dotenv
#
.env.*
.env

# sentry
sentry.properties

# ESLint
.eslintcache

# Android signing key
MetronomeWalletSigningKey.json
133 changes: 80 additions & 53 deletions .travis.yml
@@ -1,71 +1,98 @@
branches:
only:
- fastlane
addons:
ssh_known_hosts: github.com # required to allow git clone certicates repo

notifications:
email:
on_success: never
on_failure: always

cache:
bundler: true
directories:
- $HOME/.npm

matrix:
include:
- language: android
jdk: oraclejdk8
sudo: required
dist: precise
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- node_modules
android:
components:
- platform-tools
- tools
- build-tools-27.0.3
- android-27
- extra-android-m2repository
- extra-google-google_play_services
- extra-google-m2repository
licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+
- stage: Deploy iOS 🍏
os: osx
osx_image: xcode10.1
language: objective-c
node_js: false

before_install:
- nvm install 8
- nvm install 8.15.0 # enforce using same version as local builds
- npm i -g npm@6.4.1 # enforce using same version as local builds
- nvm alias default 8.15.0 # otherwise sentry-cli will fail with a cryptic error
- node --version
- npm --version
- chmod +x ./android/gradlew
- openssl aes-256-cbc -K $encrypted_2cfeec998f68_key -iv $encrypted_2cfeec998f68_iv -in android/sentry.properties.enc -out android/sentry.properties -d
- openssl aes-256-cbc -K $encrypted_e9512e60983f_key -iv $encrypted_e9512e60983f_iv -in ios/sentry.properties.enc -out ios/sentry.properties -d
- openssl aes-256-cbc -K $encrypted_f51edf0f11bf_key -iv $encrypted_f51edf0f11bf_iv -in android/app/metronome-wallet.keystore.enc -out android/app/metronome-wallet.keystore -d
- gem install fastlane --no-rdoc --no-ri --no-document --quiet
- gem install fastlane --no-document --quiet

# Decrypt SSH deploy key for GitHub certificates repo and add to agent
- openssl aes-256-cbc -K $encrypted_89b232081b73_key -iv $encrypted_89b232081b73_iv
-in github_deploy_key.enc -out github_deploy_key -d
- chmod 600 github_deploy_key
- eval $(ssh-agent -s)
- ssh-add github_deploy_key

# Decrypt Sentry properties file and add copy to /ios directory
- openssl aes-256-cbc -K $encrypted_ace616ffe366_key -iv $encrypted_ace616ffe366_iv
-in sentry.properties.enc -out ios/sentry.properties -d

install:
- npm i -f
- npm ci || travis_terminate 1

script:
- cd android
- fastlane beta
branches:
only:
- fastlane
- language: objective-c
os: osx
osx_image: xcode9.0
- npm run ios:fix-third-party || travis_terminate 1

# Create .env file
- npm run env || travis_terminate 1
- cat .env

# supposedly this shouldn't be necesary, possible RN bug?
# see https://github.com/facebook/react-native/issues/18472
- npm i -g react-native-cli@2.0.1
- react-native info
- npm run ios:bundle -- --dev false || travis_terminate 1

- npm run ios:beta

- stage: Deploy Android 🤖
language: android
jdk: oraclejdk8
node_js: false
android:
components:
- tools
- platform-tools
- android-27
- extra-google-m2repository
- extra-google-google_play_services
before_install:
- nvm install 8
- nvm install 8.15.0 # enforce using same version as local builds
- npm i -g npm@6.4.1 # enforce using same version as local builds
- nvm alias default 8.15.0 # otherwise sentry-cli will fail with a cryptic error
- node --version
- npm --version
- gem install fastlane --no-rdoc --no-ri --no-document --quiet
- openssl aes-256-cbc -K $encrypted_2cfeec998f68_key -iv $encrypted_2cfeec998f68_iv -in android/sentry.properties.enc -out android/sentry.properties -d
- openssl aes-256-cbc -K $encrypted_e9512e60983f_key -iv $encrypted_e9512e60983f_iv -in ios/sentry.properties.enc -out ios/sentry.properties -d
- gem install fastlane --no-document --quiet
- yes | $ANDROID_HOME/tools/bin/sdkmanager "build-tools;27.0.3" # accept android licenses

# Decrypt Sentry properties file and add copy to /android directory
- openssl aes-256-cbc -K $encrypted_ace616ffe366_key -iv $encrypted_ace616ffe366_iv
-in sentry.properties.enc -out android/sentry.properties -d

- openssl aes-256-cbc -K $encrypted_2cfeec998f68_key -iv $encrypted_2cfeec998f68_iv
-in metronome-wallet.keystore.enc -out android/metronome-wallet.keystore -d

- openssl aes-256-cbc -K $encrypted_5573d999f481_key -iv $encrypted_5573d999f481_iv
-in MetronomeWalletSigningKey.json.enc -out MetronomeWalletSigningKey.json -d

install:
- npm i -f
- npm ci || travis_terminate 1

script:
- cd ios
- fastlane beta
branches:
only:
- fastlane
# Create .env file
- npm run env || travis_terminate 1
- cat .env

- npm run gradle-properties
- npm run android:beta
Binary file added MetronomeWalletSigningKey.json.enc
Binary file not shown.
3 changes: 0 additions & 3 deletions android/Gemfile

This file was deleted.

25 changes: 10 additions & 15 deletions android/app/build.gradle
@@ -1,4 +1,5 @@
apply plugin: "com.android.application"
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"

import com.android.build.OutputFile

Expand Down Expand Up @@ -94,23 +95,16 @@ def enableSeparateBuildPerCPUArchitecture = false
*/
def enableProguardInReleaseBuilds = false

def (major, minor, patch) = getNpmVersion().tokenize('.')

def getNpmVersionArray() { // major [0], minor [1], patch [2]
def (major, minor, patch) = getNpmVersion().tokenize('.')
return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
}

android {
compileSdkVersion 27
buildToolsVersion "27.0.2"
buildToolsVersion "27.0.3"

defaultConfig {
applicationId "sh.autonomous.wallet.mobile"
minSdkVersion 18
targetSdkVersion 27
versionCode 19 // versionMajor * 10000 + versionMinor * 100 + versionPatch
versionName "${versionMajor}.${versionMinor}.${versionPatch}"
versionCode project.hasProperty('VERSION_CODE') ? Integer.parseInt(VERSION_CODE) : 1
versionName project.hasProperty('VERSION_NAME') ? VERSION_NAME : "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
Expand All @@ -125,11 +119,11 @@ android {
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
if (project.hasProperty('METRONOME_RELEASE_STORE_FILE')) {
storeFile file(METRONOME_RELEASE_STORE_FILE)
storePassword METRONOME_RELEASE_STORE_PASSWORD
keyAlias METRONOME_RELEASE_KEY_ALIAS
keyPassword METRONOME_RELEASE_KEY_PASSWORD
}
}
}
Expand All @@ -156,6 +150,7 @@ android {
}

dependencies {
compile project(':react-native-config')
compile project(':react-native-google-analytics-bridge')
compile project(':react-native-sentry')
compile project(':react-native-version-number')
Expand Down
Binary file removed android/app/metronome-wallet.keystore.enc
Binary file not shown.
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.lugg.ReactNativeConfig.ReactNativeConfigPackage;
import com.idehub.GoogleAnalyticsBridge.GoogleAnalyticsBridgePackage;
import io.sentry.RNSentryPackage;
import com.apsl.versionnumber.RNVersionNumberPackage;
Expand Down Expand Up @@ -32,6 +33,7 @@ public boolean getUseDeveloperSupport() {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new ReactNativeConfigPackage(),
new GoogleAnalyticsBridgePackage(),
new RNSentryPackage(),
new RNVersionNumberPackage(),
Expand Down
16 changes: 0 additions & 16 deletions android/build.gradle
Expand Up @@ -26,24 +26,8 @@ allprojects {
}
}

def getNpmVersion() {
def inputFile = new File("../package.json")
def packageJson = new JsonSlurper().parseText(inputFile.text)
return packageJson["version"]
}

def getNpmVersionArray() { // major [0], minor [1], patch [2]
def (major, minor, patch) = getNpmVersion().tokenize('.')
return [Integer.parseInt(major), Integer.parseInt(minor), Integer.parseInt(patch)] as int[]
}

subprojects {
ext {
def npmVersion = getNpmVersionArray()
versionMajor = npmVersion[0]
versionMinor = npmVersion[1]
versionPatch = npmVersion[2]
}
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
Expand Down
2 changes: 0 additions & 2 deletions android/fastlane/Appfile

This file was deleted.

39 changes: 0 additions & 39 deletions android/fastlane/Fastfile

This file was deleted.

2 changes: 1 addition & 1 deletion android/gradle.properties
Expand Up @@ -18,4 +18,4 @@
# org.gradle.parallel=true

android.useDeprecatedNdk=true
android.enableAapt2=false
android.enableAapt2=false
4 changes: 0 additions & 4 deletions android/sentry.properties.enc

This file was deleted.

2 changes: 2 additions & 0 deletions android/settings.gradle
@@ -1,4 +1,6 @@
rootProject.name = 'MetronomeWallet'
include ':react-native-config'
project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android')
include ':react-native-google-analytics-bridge'
project(':react-native-google-analytics-bridge').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-google-analytics-bridge/android')
include ':react-native-sentry'
Expand Down

0 comments on commit 91e64fb

Please sign in to comment.