Improve CircleCI cache

This commit is contained in:
Rodrigo Nascimento 2017-11-05 21:01:29 -02:00
parent 0126bc29fd
commit f9942f3321
No known key found for this signature in database
GPG Key ID: CFCE33B7B01AC335
2 changed files with 78 additions and 55 deletions

78
.circleci/config.yml Normal file
View File

@ -0,0 +1,78 @@
defaults: &defaults
working_directory: ~/repo
version: 2
jobs:
build:
<<: *defaults
docker:
- image: circleci/android:api-26-alpha
environment:
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"
JVM_OPTS: -Xmx2048m
TERM: dumb
BASH_ENV: "~/.nvm/nvm.sh"
steps:
- checkout
- run:
name: Install Node 8
command: |
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
source ~/.nvm/nvm.sh
nvm install 8
npm install
- restore_cache:
key: node-modules-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
- run:
name: Install NPM modules
command: |
npm install
- restore_cache:
key: android-{{ checksum ".circleci/config.yml" }}-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
- run:
name: Install Android Depedencies
command: |
cd android
./gradlew androidDependencies
- run:
name: Build Android App
command: |
cd android
echo $KEYSTORE_BASE64 | base64 --decode > ./app/$KEYSTORE
echo -e "KEYSTORE=$KEYSTORE" > ./gradle.properties
echo -e "KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties
echo -e "KEY_ALIAS=$KEY_ALIAS" >> ./gradle.properties
echo -e "KEY_PASSWORD=$KEYSTORE_PASSWORD" >> ./gradle.properties
./gradlew assembleRelease
mkdir -p /tmp/build
mv app/build/outputs /tmp/build/
- store_artifacts:
path: /tmp/build/outputs
- save_cache:
key: node-modules-{{ checksum ".circleci/config.yml" }}-{{ checksum "package.json" }}
paths:
- ./node_modules
- save_cache:
key: android-{{ checksum ".circleci/config.yml" }}-{{ checksum "android/build.gradle" }}-{{ checksum "android/app/build.gradle" }}
paths:
- ~/.gradle
workflows:
version: 2
build-and-test:
jobs:
- build

View File

@ -1,55 +0,0 @@
machine:
node:
version: 8
environment:
YARN_VERSION: 0.18.1
# Needed for Android SDK installation bash script (see below)
PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"'
dependencies:
pre:
# Install YARN
- node -v
- echo $KEYSTORE_BASE64 | base64 --decode > ./android/app/rocketchat-rn.keystore
- echo -e "KEYSTORE=$KEYSTORE" >> ./android/gradle.properties
- echo -e "KEYSTORE_PASSWORD=$KEYSTORE_PASSWORD" >> ./android/gradle.properties
- echo -e "KEY_ALIAS=$KEY_ALIAS" >> ./android/gradle.properties
- echo -e "KEY_PASSWORD=$KEYSTORE_PASSWORD" >> ./android/gradle.properties
override:
# The Android Gradle build will need the Android signing keystore keys setup
- echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.3,build-tools-25.0.2,build-tools-26.0.1,android-23,extra-google-m2repository,extra-google-google_play_services,extra-android-m2repository
- echo y | $ANDROID_HOME/tools/bin/sdkmanager --update
- echo y | $ANDROID_HOME/tools/bin/sdkmanager --licenses
# Install node modules
- yarn
# - ./node_modules/.bin/react-native bundle --platform android --dev false --entry-file index.android.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/
- cd android && ./gradlew assembleRelease
- mv ./android/app/build/outputs/ $CIRCLE_ARTIFACTS
cache_directories:
# Let's speed up the next build by cacheing installed dependencies
- ~/.yarn
- ~/.cache/yarn
- vendor/bundle
- node_modules
- ~/Library/Caches/CocoaPods
- /usr/local/android-sdk-linux/platforms/android-25
- /usr/local/android-sdk-linux/build-tools/25.0.0
- /usr/local/android-sdk-linux/extras/android/m2repository
deployment:
production: # just a label; label names are completely up to you
branch: master
commands:
- ./gradlew assembleRelease
-Dorg.gradle.project.track=production
beta:
branch: develop
commands:
- ./gradlew assembleRelease
-Dorg.gradle.project.track=beta
alpha:
branch: circle-ci
commands:
- android/gradlew publishApkProductionRelease