Skip to content

Instantly share code, notes, and snippets.

@OmarKRostom
Last active June 29, 2020 13:58
Show Gist options
  • Save OmarKRostom/cf15de83c41582f95814484984e2b440 to your computer and use it in GitHub Desktop.
Save OmarKRostom/cf15de83c41582f95814484984e2b440 to your computer and use it in GitHub Desktop.
Your quick and reliable CircleCI configuration for Android
version: 2.1
references:
#Android Configuration Block
android_config: &android_config
working_directory: ~/{MY-APP}
docker:
- image: circleci/android:api-29
environment:
_JAVA_OPTIONS: -Xmx2048m -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
GRADLE_OPTS: -Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dorg.gradle.caching=true -Dorg.gradle.configureondemand=true -Dkotlin.compiler.execution.strategy=in-process -Dkotlin.incremental=false
commands:
#Steps For Build
restore_gradle_cache:
description: "Restore gradle cache"
steps:
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
restore_ruby_cache:
description: "Restore gem/rails cache"
steps:
- restore_cache:
key: gems-{{ checksum "Gemfile.lock" }}
decode_signing_props:
description: "Read android gradle signing props file from circle ci env"
steps:
# Convert your signing.props file using the following command
# base64 /path/to/signing.properties > signing_props.txt
# The below ling will rollback the base64 into a file as on your local machine
# Make sure to have an entry SIGNING_CONFIG in envirnoment variables in CircleCI project settings page
- run: echo $SIGNING_CONFIG | base64 -d > signing.properties
decode_signing_key:
description: "Read android signing key from circle ci env"
steps:
# Convert your keystore file using the following command
# base64 /path/to/keystore.jks > keystore_as_base_64.txt
# The below ling will rollback the base64 into a file as on your local machine
# Make sure to have an entry KEYSTORE_BASE64 in envirnoment variables in CircleCI project settings page
- run: echo $KEYSTORE_BASE64 | base64 -d > {MY_APP_BETA}.jks
check_ruby_dependencies:
description: "Check if any dependencies in GemFile is missing"
steps:
- run: bundle check || bundle install --path vendor/bundle
- run: bundle update fastlane
check_firebase_cli_installed:
description: "Check if firebase CLI is installed"
steps:
- run: curl -sL firebase.tools | bash
exec_build_for_{MY_APP_BETA}_via_fastlane:
description: "Run Fastlane for {MY_APP_BETA} beta build"
steps:
- run: bundle exec fastlane {MY_APP_BETA}
save_gradle_cache:
description: "Save last synced gradle cache after build"
steps:
- save_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
paths:
- ~/.gradle
save_ruby_cache:
description: "Save last synced ruby cached after build"
steps:
- save_cache:
key: gems-{{ checksum "Gemfile.lock" }}
paths:
- vendor/bundle
jobs:
betaBuild:
<<: *android_config
steps:
- checkout
- restore_gradle_cache
- restore_ruby_cache
- decode_signing_props
- decode_signing_key
- check_ruby_dependencies
- check_firebase_cli_installed
- exec_build_for_{MY_APP_BETA}_via_fastlane
- save_gradle_cache
- save_ruby_cache
workflows:
version: 2.1
betaBuild:
jobs:
- betaBuild:
filters:
branches:
only: {MY_APP_BETA_BRANCH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment