Created
April 8, 2020 15:35
-
-
Save cgradwohl/a2bad42d4dea155d087799728601ad2b to your computer and use it in GitHub Desktop.
first pipeline implementation
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: staging | |
workflows: | |
setup: | |
steps: | |
- [email protected]: | |
run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}' | |
- [email protected]: {} | |
- [email protected]: | |
title: Set Full Build | |
inputs: | |
- content: |- | |
#!/bin/bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
if [[ "$GIT_CLONE_COMMIT_MESSAGE_SUBJECT" == *"[FULL BUILD]"* ]] | |
then | |
envman add --key RUN_ARCHIVE --value true | |
else | |
envman add --key RUN_ARCHIVE --value false | |
fi | |
- [email protected]: | |
title: Set Install Native Deps | |
inputs: | |
- content: |- | |
#!/bin/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 | |
- [email protected]: | |
title: Set Build Description | |
inputs: | |
- content: |- | |
#!/bin/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 | |
- [email protected]: | |
run_if: '{{getenv "USE_DETOX" | ne "true"}}' | |
title: Remove detox (If USE_DETOX != true) | |
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 | |
- [email protected]: | |
title: Install npm-cache | |
inputs: | |
- content: |- | |
#!/bin/bash | |
npm install -g npm-cache | |
- cache-pull: {} | |
- [email protected]: | |
title: npm-cache install | |
inputs: | |
- content: |- | |
#!/bin/bash | |
npm-cache install --cacheDirectory . | |
- cache-push: | |
inputs: | |
- cache_paths: "./npm" | |
- [email protected]: | |
inputs: | |
- command: install | |
title: npm install | |
- [email protected]: | |
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) | |
- [email protected]: | |
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 | |
title: Set build number in dist.js | |
- npm: | |
title: Install CodePush CLI | |
inputs: | |
- command: install -g code-push-cli | |
setup_ios: | |
steps: | |
- [email protected]: | |
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" | |
- [email protected]: | |
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 | |
test_ios: | |
steps: | |
- [email protected]: | |
run_if: '{{getenv "USE_DETOX" | eq "true"}}' | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
# write your script here | |
echo "Building and running detox" | |
npm run build:e2e | |
npm run ci:test:e2e | |
title: Run detox tests | |
archive_ios: | |
steps: | |
- [email protected]: | |
inputs: | |
- content: |- | |
#!/usr/bin/env bash | |
# fail if any commands fails | |
set -e | |
# debug log | |
set -x | |
# Eventually to be replaced by an if statement depending on environment | |
KEY=$CODE_PUSH_KEY_STAGING | |
echo "Updating CodePush deploy key to: $KEY" | |
/usr/libexec/PlistBuddy -c "Set :CodePushDeploymentKey $KEY" ios/Sibly/Info.plist | |
title: Inject CodePush deployment key | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- team_id: LL8G5N933A | |
- distribution_type: "$IOS_EXPORT_METHOD" | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- plist_path: "$BITRISE_SOURCE_DIR/ios/Sibly/Info.plist" | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- team_id: LL8G5N933A | |
- export_method: "$IOS_EXPORT_METHOD" | |
- compile_bitcode: 'no' | |
- upload_bitcode: 'no' | |
- configuration: Release | |
- [email protected]: | |
title: CodePush Release iOS | |
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 $CODE_PUSH_APP_ID --token $APPCENTER_ACCESS_TOKEN --quiet --output-dir ./build --deployment-name $ENVIRONMENT --description "\n$BUILD_DESCRIPTION" | |
- [email protected]: | |
title: Update Sentry bundle | |
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 | |
# DEPLOY_ENVIRONMENT="staging" | |
SENTRY_AUTH_TOKEN=$SENTRY_TOKEN SENTRY_PROPERTIES="ios/sentry.properties" $(npm bin)/sentry-cli react-native appcenter $CODE_PUSH_APP_ID ios "./build/$BUILD_DIR" | |
envs: | |
- opts: | |
is_expand: false | |
CODE_PUSH_KEY_STAGING: iLv4Pzi8NE7PhqM38m0br5sOjqn8xp36MtRGJ | |
- opts: | |
is_expand: false | |
CODE_PUSH_KEY_PRODUCTION: 7XwknkTUErxKmRQFODTZ7EOPjQBPuyaIM3gsT | |
- opts: | |
is_expand: false | |
CODE_PUSH_APP_ID: work-mtnm/Typhon-iOS | |
setup_android: | |
steps: | |
- [email protected]: | |
title: Android Keystore Downloader | |
inputs: | |
- destination: "$BITRISE_SOURCE_DIR/android/app/sibly.keystore" | |
- source: "$BITRISEIO_ANDROID_KEYSTORE_URL" | |
- [email protected]: | |
title: Android Google Services JSON Downloader | |
inputs: | |
- destination: "$BITRISE_SOURCE_DIR/android/app/google-services.json" | |
- source: "$BITRISEIO_ANDROID_GOOGLE_SERVICES_JSON_URL" | |
- [email protected]: | |
run_if: '{{getenv "INSTALL_NATIVE_DEPS" | eq "true"}}' | |
inputs: | |
- gradlew_path: "$PROJECT_LOCATION/gradlew" | |
- [email protected]: | |
inputs: | |
- command: run android:jetify | |
title: Android jetify | |
- [email protected]: | |
inputs: | |
- path: "$ORIG_WORK_DIR/android" | |
- [email protected]: {} | |
- [email protected]: | |
inputs: | |
- path: "$ORIG_WORK_DIR" | |
archive_android: | |
steps: | |
- [email protected]: | |
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=$CODE_PUSH_KEY_STAGING | |
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 | |
title: Inject CodePush deployment key | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- path: "$ORIG_WORK_DIR/android" | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- gradlew_path: "./gradlew" | |
- gradle_task: bundleRelease assembleRelease | |
title: Bundle & assemble Android release | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
inputs: | |
- path: "$ORIG_WORK_DIR" | |
- cache-push: | |
inputs: | |
- cache_paths: |- | |
$HOME/.gradle | |
./android/.gradle | |
- ignore_check_on_paths: |- | |
$HOME/.gradle/caches/*.lock | |
./android/.gradle/*.lock | |
./android/.gradle/*.bin | |
- [email protected]: | |
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 $CODE_PUSH_APP_ID --token $APPCENTER_ACCESS_TOKEN --quiet --output-dir ./build --deployment-name $ENVIRONMENT --description "\n$BUILD_DESCRIPTION" | |
title: CodePush Release Android | |
- [email protected]: | |
title: Update Sentry bundle | |
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 | |
# DEPLOY_ENVIRONMENT="staging" | |
SENTRY_AUTH_TOKEN=$SENTRY_TOKEN SENTRY_PROPERTIES="android/sentry.properties" $(npm bin)/sentry-cli react-native appcenter $CODE_PUSH_APP_ID android "./build/$BUILD_DIR" | |
envs: | |
- opts: | |
is_expand: false | |
CODE_PUSH_KEY_STAGING: ZWKLUAdxJ78PuaoOxE4RUkAG8ia8865k-76DA | |
- opts: | |
is_expand: false | |
CODE_PUSH_KEY_PRODUCTION: NQcVxqrOrXtk7Y5qQKEG7pUXIiOo7Snc0qM9i | |
- opts: | |
is_expand: false | |
CODE_PUSH_APP_ID: work-mtnm/Typhon-Android | |
deploy: | |
steps: | |
- [email protected]: | |
run_if: '{{getenv "RUN_ARCHIVE" | eq "true"}}' | |
staging: | |
before_run: | |
- setup | |
- setup_ios | |
- test_ios | |
- setup_android | |
after_run: | |
- archive_ios | |
- archive_android | |
- deploy | |
steps: | |
- [email protected]: | |
title: Set ENVIRONMENT | |
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_EXPORT_METHOD --value "ad-hoc" | |
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 | |
meta: | |
bitrise.io: | |
machine_type: standard | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment