Skip to content

Instantly share code, notes, and snippets.

@sergeylaptev
Last active February 12, 2019 15:56
Show Gist options
  • Save sergeylaptev/30821368a887f3ccae93ebc8734f749c to your computer and use it in GitHub Desktop.
Save sergeylaptev/30821368a887f3ccae93ebc8734f749c to your computer and use it in GitHub Desktop.
Bitrise Android config
---
format_version: '6'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: android
workflows:
_init_install:
steps:
- [email protected]:
title: Activate App SSH key
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- [email protected]: {}
- [email protected]:
title: Install npm-cache
inputs:
- content: |-
#!/bin/bash
npm install -g npm-cache
- [email protected]: {}
- [email protected]:
title: npm-cache install
inputs:
- content: npm-cache install --cacheDirectory .
- [email protected]:
inputs:
- cache_paths: "./npm"
meta:
bitrise.io:
stack: linux-docker-android
_make_apk:
steps:
- [email protected]:
inputs:
- build_gradle_path: android/app/build.gradle
- new_version_code: "$BITRISE_BUILD_NUMBER"
- [email protected]:
inputs:
- destination: "$ENVFILE_DESTINATION"
- source: "$ENVFILE_URL"
- [email protected]:
inputs:
- content: |-
#!/usr/bin/env bash
echo "Increase inotify file watch limit to achieve building multiple apk in the same workflow"
# fail if any commands fails
set -e
# debug log
set -x
# INFO: https://github.com/guard/listen/wiki/Increasing-the-amount-of-inotify-watchers#the-technical-details
eval "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"
- [email protected]:
title: gradlew
inputs:
- content: export ENVFILE=$ENVFILE && cd android && ./gradlew $GRADLEW_TASKNAME
- [email protected]:
inputs:
- apk_path: "/bitrise/src/android/app/build/outputs/apk/$GRADLE_FLAVOR_PRODUCT/$UNSIGNED_APK_FILENAME"
- keystore_url: "$BITRISEIO_ANDROID_KEYSTORE_URL"
- keystore_password: "$BITRISEIO_ANDROID_KEYSTORE_PASSWORD"
- keystore_alias: "$BITRISEIO_ANDROID_KEYSTORE_ALIAS"
- private_key_password: "$BITRISEIO_ANDROID_KEYSTORE_PRIVATE_KEY_PASSWORD"
- [email protected]:
title: cp apk
inputs:
- content: cp $BITRISE_SIGNED_APK_PATH $BITRISE_DEPLOY_DIR/$SIGNED_APK_FILENAME
- [email protected]:
is_always_run: false
inputs:
- notify_email_list: ''
before_run:
after_run:
_slack_message:
steps:
- [email protected]:
inputs:
- webhook_url: "$SLACK_WEBHOOK_URL"
- channel: "#bitrise"
- from_username: Android $ENVIRONMENT Build Succeeded
- from_username_on_error: Android $ENVIRONMENT Build Failed
- message: 'Test the changes on the latest $ENVIRONMENT build. Click here
to download the build: $BITRISE_PUBLIC_INSTALL_PAGE_URL'
- message_on_error: 'Click here to find out why the build failed: $BITRISE_PUBLIC_INSTALL_PAGE_URL'
- emoji: ":confetti_ball:"
- emoji_on_error: ":shrug:"
development:
steps:
- script:
title: Set Environment
inputs:
- content: |-
#!/bin/bash
envman add --key ENVFILE --value .env.dev
envman add --key ENVFILE_URL --value "$BITRISEIO_ENVFILE_DEV_URL"
envman add --key ENVFILE_DESTINATION --value ".env.dev"
envman add --key ENVIRONMENT --value "[DEV] Synchronic"
envman add --key GRADLEW_TASKNAME --value assembleDevelopmentRelease
envman add --key UNSIGNED_APK_FILENAME --value app-development-release-unsigned.apk
envman add --key GRADLE_FLAVOR_PRODUCT --value development
envman add --key SIGNED_APK_FILENAME --value development.apk
before_run:
- _init_install
after_run:
- _make_apk
- _slack_message
production:
steps:
- script:
title: Set Environment
inputs:
- content: |-
#!/bin/bash
envman add --key ENVFILE --value .env
envman add --key ENVFILE_URL --value "$BITRISEIO_ENVFILE_URL"
envman add --key ENVFILE_DESTINATION --value ".env"
envman add --key ENVIRONMENT --value "[PROD] Synchronic"
envman add --key GRADLEW_TASKNAME --value assembleProductionRelease
envman add --key UNSIGNED_APK_FILENAME --value app-production-release-unsigned.apk
envman add --key GRADLE_FLAVOR_PRODUCT --value production
envman add --key SIGNED_APK_FILENAME --value production.apk
before_run:
- _init_install
after_run:
- _make_apk
- _slack_message
trigger_map:
- push_branch: production
workflow: production
- push_branch: master
workflow: development
- push_branch: bitrise
workflow: development
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment