Skip to content

Instantly share code, notes, and snippets.

@sergeylaptev
Last active February 12, 2019 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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:
- activate-ssh-key@4.0.3:
title: Activate App SSH key
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
- git-clone@4.0.14: {}
- script@1.1.5:
title: Install npm-cache
inputs:
- content: |-
#!/bin/bash
npm install -g npm-cache
- cache-pull@2.0.1: {}
- script@1.1.5:
title: npm-cache install
inputs:
- content: npm-cache install --cacheDirectory .
- cache-push@2.0.5:
inputs:
- cache_paths: "./npm"
meta:
bitrise.io:
stack: linux-docker-android
_make_apk:
steps:
- change-android-versioncode-and-versionname@1.1.1:
inputs:
- build_gradle_path: android/app/build.gradle
- new_version_code: "$BITRISE_BUILD_NUMBER"
- file-downloader@1.0.1:
inputs:
- destination: "$ENVFILE_DESTINATION"
- source: "$ENVFILE_URL"
- script@1.1.5:
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"
- script@1.1.5:
title: gradlew
inputs:
- content: export ENVFILE=$ENVFILE && cd android && ./gradlew $GRADLEW_TASKNAME
- sign-apk@1.2.4:
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"
- script@1.1.5:
title: cp apk
inputs:
- content: cp $BITRISE_SIGNED_APK_PATH $BITRISE_DEPLOY_DIR/$SIGNED_APK_FILENAME
- deploy-to-bitrise-io@1.3.19:
is_always_run: false
inputs:
- notify_email_list: ''
before_run:
after_run:
_slack_message:
steps:
- slack@3.1.2:
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