Created
May 5, 2020 17:31
-
-
Save cgradwohl/4cc54c53601ac35c41a8b8cb90760731 to your computer and use it in GitHub Desktop.
bitrise.yml May 5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
format_version: '8' | |
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git | |
project_type: react-native | |
trigger_map: | |
- push_branch: master | |
workflow: production | |
- push_branch: staging | |
workflow: staging | |
- push_branch: "*" | |
workflow: development | |
- pull_request_target_branch: staging | |
workflow: pull_request | |
- pull_request_target_branch: master | |
workflow: pull_request | |
workflows: | |
development: | |
after_run: | |
- primary | |
steps: | |
- script@1.1.6: | |
title: Development Workflow | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
envman add --key ENVIRONMENT --value "Development" | |
envman add --key IOS_DISTRIBUTION_TYPE --value "ad-hoc" | |
staging: | |
after_run: | |
- primary | |
steps: | |
- script@1.1.6: | |
title: Staging Workflow | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
envman add --key ENVIRONMENT --value "Staging" | |
envman add --key IOS_CODE_PUSH_KEY --value $IOS_CODE_PUSH_KEY_STAGING | |
envman add --key ANDROID_CODE_PUSH_KEY --value $ANDROID_CODE_PUSH_KEY_STAGING | |
envman add --key SENTRY_TOKEN --value $SENTRY_TOKEN_STAGING | |
envman add --key IOS_DISTRIBUTION_TYPE --value "ad-hoc" | |
production: | |
after_run: | |
- primary | |
steps: | |
- script@1.1.6: | |
title: Production Workflow | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
envman add --key ENVIRONMENT --value "Production" | |
envman add --key IOS_CODE_PUSH_KEY --value $IOS_CODE_PUSH_KEY_PRODUCTION | |
envman add --key ANDROID_CODE_PUSH_KEY --value $ANDROID_CODE_PUSH_KEY_PRODUCTION | |
envman add --key SENTRY_TOKEN --value $SENTRY_TOKEN_PRODUCTION | |
envman add --key IOS_DISTRIBUTION_TYPE --value "app-store" | |
envman add --key ANDROID_TRACK --value "beta" | |
pull_request: | |
after_run: | |
- setup | |
- setup_ios | |
- test_ios | |
steps: | |
- script@1.1.6: | |
title: Pull Request Workflow | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
echo "Starting the Pull Request Workflow" | |
primary: | |
after_run: | |
- setup | |
- setup_ios | |
- setup_android | |
- archive_ios | |
- archive_android | |
- deploy_android | |
- deploy_ios | |
- deploy_bitrise | |
steps: | |
- script@1.1.6: | |
title: Primary Workflow | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
echo "Starting the Primary Workflow for the ${ENVIRONMENT} Environment." | |
setup: | |
steps: | |
- activate-ssh-key@4.0.3: | |
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' | |
- git-clone@4.0.14: {} | |
- script@1.1.6: | |
title: Set RUN_ARCHIVE | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [[ "$GIT_CLONE_COMMIT_MESSAGE_SUBJECT" == *"[FULL BUILD]"* ]] || [[ "$ENVIRONMENT" == "Development" ]] | |
then | |
envman add --key RUN_ARCHIVE --value true | |
else | |
envman add --key RUN_ARCHIVE --value false | |
fi | |
- script@1.1.6: | |
title: Set DEPLOY_ARCHIVE | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [[ "$GIT_CLONE_COMMIT_MESSAGE_SUBJECT" == *"[FULL BUILD]"* ]] && [[ "$ENVIRONMENT" == "Production" ]] | |
then | |
envman add --key DEPLOY_ARCHIVE --value true | |
else | |
envman add --key DEPLOY_ARCHIVE --value false | |
fi | |
- script@1.1.6: | |
title: Set DEPLOY_UPDATE (CodePush and Sentry) | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [[ "$ENVIRONMENT" == "Development" ]] | |
then | |
envman add --key DEPLOY_UPDATE --value false | |
else | |
envman add --key DEPLOY_UPDATE --value true | |
fi | |
- script@1.1.6: | |
title: Set USE_DETOX | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
# TODO: the purpose of this workflow is to determine if USE_DETOX should be true ... | |
# TODO: so first, figure out what is wrong with detox in bitrise environment | |
# TODO: set USE_DETOX to true when applicable (figure out when we want to run the tests) | |
envman add --key USE_DETOX --value false | |
- script@1.1.6: | |
title: Set Install Native Deps | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [ "$RUN_ARCHIVE" = true ] || [ "$USE_DETOX" = true ] | |
then | |
envman add --key INSTALL_NATIVE_DEPS --value true | |
else | |
envman add --key INSTALL_NATIVE_DEPS --value false | |
fi | |
- script@1.1.6: | |
title: Set Build Description | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
brew install jq | |
LAST_HASH=$(curl -X GET "https://api.bitrise.io/v0.1/apps/ab1dc0a175ba5d60/builds?sort_by=created_at&workflow=staging" -H "accept: application/json" -H "Authorization: $BITRISE_TOKEN" | jq -r '[.data[]|select((.status == 0) or (.status == 1))][0].commit_hash') | |
envman add --key LAST_COMMIT_HASH --value $LAST_HASH | |
- script@1.1.6: | |
run_if: '{{getenv "USE_DETOX" | ne "true"}}' | |
title: if USE_DETOX != true, then remove detox | |
inputs: | |
- content: | | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
brew install jq | |
echo $(jq "del(.devDependencies.detox)" <<< cat $BITRISE_SOURCE_DIR/package.json) > $BITRISE_SOURCE_DIR/package.json | |
- script@1.1.6: | |
title: Install npm-cache | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
npm install -g npm-cache | |
- cache-pull: {} | |
- script@1.1.6: | |
title: npm-cache install | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
npm-cache install --cacheDirectory . | |
- cache-push: | |
inputs: | |
- cache_paths: "./npm" | |
- npm@1.0.2: | |
inputs: | |
- command: install | |
title: npm install | |
- script@1.1.6: | |
run_if: '{{getenv "USE_DETOX" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
brew tap wix/brew | |
brew install applesimutils | |
title: Install detox deps (If USE_DETOX == true) | |
- script@1.1.6: | |
title: Set build number in dist.js | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
echo "module.exports = $BITRISE_BUILD_NUMBER;" > dist.js | |
- script@1.1.6: | |
title: Set build settings | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [[ "$ENVIRONMENT" == "Production" ]] | |
then | |
echo "\""\""" > build.json | |
fi | |
- npm: | |
title: Install CodePush CLI | |
inputs: | |
- command: install -g code-push-cli | |
setup_ios: | |
steps: | |
- file-downloader@1.0.1: | |
title: iOS Google Services Plist Downloader | |
inputs: | |
- destination: "$BITRISE_SOURCE_DIR/ios/GoogleService-Info.plist" | |
- source: "$BITRISEIO_IOS_GOOGLE_SERVICES_PLIST_URL" | |
- cocoapods-install: | |
run_if: '{{getenv "INSTALL_NATIVE_DEPS" | eq "true"}}' | |
- cache-push: | |
run_if: '{{getenv "INSTALL_NATIVE_DEPS" | eq "true"}}' | |
inputs: | |
- cache_paths: "./ios/Pods -> ./ios/Podfile.lock" | |
- script@1.1.6: | |
title: Patch Packages | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
# brew install gnu-sed | |
# gsed -i '36i -(dispatch_queue_t)methodQueue { return dispatch_get_main_queue(); }' node_modules/react-native-onesignal/ios/RCTOneSignal/RCTOneSignalEventEmitter.m | |
# gsed -i '6i #import <UIKit/UIKit.h>' node_modules/react-native-inappbrowser-reborn/ios/RNInAppBrowser.h | |
# gsed -i 's/__IPHONE_13_0/130000/g' node_modules/react-native-inappbrowser-reborn/ios/RNInAppBrowser.m | |
npx patch-package | |
setup_android: | |
steps: | |
- file-downloader@1.0.1: | |
title: Android Keystore Downloader | |
inputs: | |
- destination: "$BITRISE_SOURCE_DIR/android/app/sibly.keystore" | |
- source: "$BITRISEIO_ANDROID_KEYSTORE_URL" | |
- file-downloader@1.0.1: | |
title: Android Google Services JSON Downloader | |
inputs: | |
- destination: "$BITRISE_SOURCE_DIR/android/app/google-services.json" | |
- source: "$BITRISEIO_ANDROID_GOOGLE_SERVICES_JSON_URL" | |
- install-missing-android-tools@2: | |
run_if: '{{getenv "INSTALL_NATIVE_DEPS" | eq "true"}}' | |
inputs: | |
- gradlew_path: "$PROJECT_LOCATION/gradlew" | |
- npm@1: | |
inputs: | |
- command: run android:jetify | |
title: Android jetify | |
- change-android-versioncode-and-versionname@1: | |
inputs: | |
- build_gradle_path: "$BITRISE_SOURCE_DIR/android/app/build.gradle" | |
test_ios: | |
steps: | |
- script@1.1.6: | |
title: Run detox tests | |
run_if: '{{getenv "USE_DETOX" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
echo "Building and running detox" | |
npm run build:e2e | |
npm run ci:test:e2e | |
archive_ios: | |
steps: | |
- script@1.1.6: | |
title: Inject CodePush deployment key | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
KEY=$IOS_CODE_PUSH_KEY | |
echo "Updating CodePush deploy key to: $KEY" | |
/usr/libexec/PlistBuddy -c "Set :CodePushDeploymentKey $KEY" ios/Sibly/Info.plist | |
- ios-auto-provision@1.5.2: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- team_id: LL8G5N933A | |
- distribution_type: "$IOS_DISTRIBUTION_TYPE" | |
- set-xcode-build-number@1.0.9: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- plist_path: "$BITRISE_SOURCE_DIR/ios/Sibly/Info.plist" | |
- set-xcode-build-number@1: | |
inputs: | |
- plist_path: "$BITRISE_SOURCE_DIR/ios/OneSignalNotificationServiceExtension/Info.plist" | |
- xcode-archive@2.7.2: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- team_id: "$SIBLY_IOS_TEAM_ID" | |
- export_method: "$IOS_DISTRIBUTION_TYPE" | |
- compile_bitcode: 'no' | |
- upload_bitcode: 'no' | |
- configuration: Release | |
archive_android: | |
steps: | |
- script@1.1.6: | |
title: Inject CodePush deployment key | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
brew install xmlstarlet | |
# Eventually to be replaced by an if statement depending on environment | |
KEY=$ANDROID_CODE_PUSH_KEY | |
echo "Updating CodePush deploy key to: $KEY" | |
xmlstarlet ed -L -u "/resources/string[@name=\"reactNativeCodePush_androidDeploymentKey\"]" -v $KEY android/app/src/main/res/values/strings.xml | |
xmlstarlet ed -L -u "/resources/string[@name=\"CodePushDeploymentKey\"]" -v $KEY android/app/src/main/res/values/strings.xml | |
- android-build@0: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- module: app | |
- variant: release | |
- build_type: aab | |
- project_location: "$BITRISE_SOURCE_DIR/android" | |
- sign-apk@1: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
- cache-push: | |
inputs: | |
- cache_paths: |- | |
$HOME/.gradle | |
./android/.gradle | |
- ignore_check_on_paths: |- | |
$HOME/.gradle/caches/*.lock | |
./android/.gradle/*.lock | |
./android/.gradle/*.bin | |
deploy_ios: | |
steps: | |
- script@1.1.6: | |
title: CodePush Release iOS | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
BUILD_DESCRIPTION=$(git log $LAST_COMMIT_HASH..$BITRISE_GIT_COMMIT --format=%B | sed '/^$/d') | |
if [ "$LAST_COMMIT_HASH" = "$BITRISE_GIT_COMMIT" ]; then | |
BUILD_DESCRIPTION=$(git log -1 --format=%B | sed '/^$/d') | |
fi | |
if [ -z "$BUILD_DESCRIPTION" ]; then | |
echo "No messages found to apply to build description"; | |
BUILD_DESCRIPTION="- No build description found" | |
fi | |
if which appcenter > /dev/null; then | |
echo "AppCenter CLI already installed." | |
else | |
echo "AppCenter CLI is not installed. Installing..." | |
npm install -g appcenter-cli | |
fi | |
appcenter codepush release-react -a $IOS_CODE_PUSH_APP_ID --token $APPCENTER_ACCESS_TOKEN --quiet --output-dir ./build --deployment-name $ENVIRONMENT --description "\n$BUILD_DESCRIPTION" | |
- script@1.1.6: | |
title: Update Sentry bundle | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
npm install @sentry/cli | |
BUILD_DIR="codePush" | |
if [ -d "build/CodePush" ]; then | |
BUILD_DIR="CodePush" | |
fi | |
SENTRY_AUTH_TOKEN=$SENTRY_TOKEN SENTRY_PROPERTIES="ios/sentry.properties" $(npm bin)/sentry-cli react-native appcenter $IOS_CODE_PUSH_APP_ID ios "./build/$BUILD_DIR" | |
- deploy-to-itunesconnect-application-loader@0: | |
run_if: '{{getenv "DEPLOY_ARCHIVE" | eq "true"}}' | |
inputs: | |
- itunescon_user: "$SIBLY_APPLE_ID" | |
- app_password: "$SIBLY_IOS_TYPHON_PASSWORD" | |
deploy_android: | |
steps: | |
- script@1.1.6: | |
title: CodePush Release Android | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
BUILD_DESCRIPTION=$(git log $LAST_COMMIT_HASH..$BITRISE_GIT_COMMIT --format=%B | sed '/^$/d') | |
if [ "$LAST_COMMIT_HASH" = "$BITRISE_GIT_COMMIT" ]; then | |
BUILD_DESCRIPTION=$(git log -1 --format=%B | sed '/^$/d') | |
fi | |
if [ -z "$BUILD_DESCRIPTION" ]; then | |
echo "No messages found to apply to build description"; | |
BUILD_DESCRIPTION="- No build description found" | |
fi | |
if which appcenter > /dev/null; then | |
echo "AppCenter CLI already installed." | |
else | |
echo "AppCenter CLI is not installed. Installing..." | |
npm install -g appcenter-cli | |
fi | |
appcenter codepush release-react -a $ANDROID_CODE_PUSH_APP_ID --token $APPCENTER_ACCESS_TOKEN --quiet --output-dir ./build --deployment-name $ENVIRONMENT --description "\n$BUILD_DESCRIPTION" | |
- script@1.1.6: | |
title: Update Sentry bundle | |
run_if: '{{getenv "DEPLOY_UPDATE" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
npm install @sentry/cli | |
BUILD_DIR="codePush" | |
if [ -d "build/CodePush" ]; then | |
BUILD_DIR="CodePush" | |
fi | |
SENTRY_AUTH_TOKEN=$SENTRY_TOKEN SENTRY_PROPERTIES="android/sentry.properties" $(npm bin)/sentry-cli react-native appcenter $ANDROID_CODE_PUSH_APP_ID android "./build/$BUILD_DIR" | |
- google-play-deploy@3: | |
run_if: '{{getenv "DEPLOY_ARCHIVE" | eq "true"}}' | |
inputs: | |
- package_name: com.sibly.sibly | |
- track: "$ANDROID_TRACK" | |
- service_account_json_key_path: "$BITRISEIO_ANDROID_SERVICE_ACCOUNT_JSON_KEY_URL" | |
deploy_bitrise: | |
steps: | |
- deploy-to-bitrise-io@1.6.0: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
app: | |
envs: | |
- opts: | |
is_expand: false | |
PROJECT_LOCATION: android | |
- opts: | |
is_expand: false | |
MODULE: app | |
- opts: | |
is_expand: false | |
VARIANT: debug | |
- opts: | |
is_expand: false | |
BITRISE_PROJECT_PATH: ios/Sibly.xcworkspace | |
- opts: | |
is_expand: false | |
BITRISE_SCHEME: Sibly | |
- opts: | |
is_expand: false | |
BITRISE_EXPORT_METHOD: development | |
- ORIG_WORK_DIR: "$BITRISE_SOURCE_DIR" | |
- opts: | |
is_expand: false | |
USE_DETOX: 'false' | |
- opts: | |
is_expand: false | |
SENTRY_ORG: siblyco | |
- opts: | |
is_expand: false | |
IOS_CODE_PUSH_APP_ID: Sibly/Typhon-iOS | |
- opts: | |
is_expand: false | |
ANDROID_CODE_PUSH_APP_ID: Sibly/Typhon-Android | |
meta: | |
bitrise.io: | |
machine_type: standard |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment