Created
April 23, 2021 20:14
-
-
Save CarterBland/3c9ec1f38a3824c4c60f3fde03031d87 to your computer and use it in GitHub Desktop.
codemagic.yaml example
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
workflows: | |
react-native-android: | |
name: React Native Android | |
max_build_duration: 120 | |
instance_type: mac_mini | |
environment: | |
vars: | |
GCLOUD_SERVICE_ACCOUNT_CREDENTIALS: # <-- Put encrypted CONTENTS of your Gloud crendentials file here | |
PACKAGE_NAME: # <-- Put your package name here e.g. com.domain.myapp | |
CM_KEYSTORE: # <-- Put your encrypted keystore file here | |
CM_KEYSTORE_PASSWORD: # <-- Put your encrypted keystore password here | |
CM_KEY_ALIAS_PASSWORD: # <-- Put your encrypted keystore alias password here | |
CM_KEY_ALIAS_USERNAME: # <-- Put your encrypted keystore alias username here | |
node: latest | |
triggering: | |
events: | |
- push | |
- tag | |
- pull_request | |
branch_patterns: | |
- pattern: master | |
include: true | |
source: true | |
- pattern: development | |
include: true | |
source: true | |
cancel_previous_builds: true | |
scripts: | |
- name: Install npm dependencies | |
script: | | |
npm install | |
- name: Jetify dependencies | |
script: | | |
npx jetify | |
- name: Set Android SDK location | |
script: | | |
echo "sdk.dir=$HOME/programs/android-sdk-macosx" > "$FCI_BUILD_DIR/android/local.properties" | |
- name: Set up keystore | |
script: | | |
echo $CM_KEYSTORE | base64 --decode > /tmp/keystore.keystore | |
cat >> "$FCI_BUILD_DIR/android/key.properties" <<EOF | |
storePassword=$CM_KEYSTORE_PASSWORD | |
keyPassword=$CM_KEY_ALIAS_PASSWORD | |
keyAlias=$CM_KEY_ALIAS_USERNAME | |
storeFile=/tmp/keystore.keystore | |
EOF | |
- &set_up_react_environment | |
name: Set up react environment variables | |
script: | | |
if [ $FCI_BRANCH == 'master' ]; then | |
echo "export default 'production';" > config/Environment.js | |
else | |
echo "export default '$FCI_BRANCH';" > config/Environment.js | |
fi | |
- name: Get build version code | |
script: | | |
set -x | |
set -e | |
LATEST_GOOGLE_PLAY_BUILD_NUMBER=$(($(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks=alpha) + 1)) | |
if [ -z LATEST_BUILD_NUMBER ]; then | |
# fallback in case no build number was found from google play. Alternatively, you can `exit 0` to fail the builds | |
echo "VERSION_CODE=$BUILD_NUMBER" > android/app/version.properties | |
else | |
echo "VERSION_CODE=$(($LATEST_GOOGLE_PLAY_BUILD_NUMBER))" > android/app/version.properties | |
fi | |
- name: Build Android release for prod | |
script: | | |
cd android && ./gradlew assembleRelease | |
artifacts: | |
- android/app/build/outputs/**/*.apk | |
publishing: | |
# See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email | |
email: | |
recipients: | |
- [email protected] | |
- [email protected] | |
notify: | |
success: true # To not receive a notification when a build succeeds | |
failure: false # To not receive a notification when a build fails | |
slack: | |
# See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack | |
channel: '#channel-name' | |
notify_on_build_start: true # To receive a notification when a build starts | |
notify: | |
success: true # To not receive a notification when a build succeeds | |
failure: false # To not receive a notification when a build fails | |
google_play: | |
# See the following link for information regarding publishing to Google Play - https://docs.codemagic.io/publishing-yaml/distribution/#google-play | |
credentials: # <-- Put your encrypted google-services.json here | |
track: alpha | |
react-native-ios: | |
name: React Native iOS | |
max_build_duration: 120 | |
instance_type: mac_mini | |
environment: | |
vars: | |
# Env vars for automatic iOS code signing | |
# See the following link for more details - https://docs.codemagic.io/code-signing-yaml/signing-ios/ | |
XCODE_WORKSPACE: # <-- Put the name of your Xcode workspace here | |
XCODE_SCHEME: # <-- Put the name of your Xcode scheme here | |
APPLE_ID: # <-- Put you encrypted Apple ID here | |
APP_SPECIFIC_PASSWORD: # <-- Put your encrypted App Specific Password here. For more information visit: https://support.apple.com/en-us/HT204397 | |
# https://appstoreconnect.apple.com/access/api | |
APP_STORE_CONNECT_ISSUER_ID: # <-- Put your App Store Connect Issuer Id here | |
APP_STORE_CONNECT_KEY_IDENTIFIER: # <-- Put your App Store Connect Key Identifier here | |
APP_STORE_CONNECT_PRIVATE_KEY: # <-- Put your App Store Connect Private Key here | |
CERTIFICATE_PRIVATE_KEY: # <-- Put your Certificate Private key here | |
BUNDLE_ID: # <-- Put your Bundle Id here e.g com.domain.myapp | |
APP_STORE_APP_ID: # <-- Put the app id number here. This is found in App Store Connect > App > General > App Information | |
node: latest | |
xcode: latest | |
cocoapods: default | |
triggering: | |
events: | |
- push | |
- tag | |
- pull_request | |
branch_patterns: | |
- pattern: master | |
include: true | |
source: true | |
- pattern: development | |
include: true | |
source: true | |
cancel_previous_builds: true | |
scripts: | |
- name: Install npm dependencies | |
script: | | |
npm install | |
- name: Install CocoaPods dependencies | |
script: | | |
cd ios && pod install | |
- name: Set up keychain to be used for codesigning using Codemagic CLI 'keychain' command | |
script: | | |
keychain initialize | |
- name: Fetch signing files | |
script: | | |
# For information about Codemagic CLI commands visit: https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/README.md | |
# For details about the --type paramater below - https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/fetch-signing-files.md#--typeios_app_adhoc--ios_app_development--ios_app_inhouse--ios_app_store--mac_app_development--mac_app_direct--mac_app_store--mac_catalyst_app_development--mac_catalyst_app_direct--mac_catalyst_app_store--tvos_app_adhoc--tvos_app_development--tvos_app_inhouse--tvos_app_store | |
app-store-connect fetch-signing-files "$BUNDLE_ID" --type IOS_APP_STORE --create | |
- name: Use system default keychain | |
script: | | |
keychain add-certificates | |
- *set_up_react_environment | |
- name: Increment build number | |
script: | | |
#!/bin/sh | |
set -e | |
set -x | |
cd $FCI_BUILD_DIR/ios | |
# agvtool new-version -all $(($BUILD_NUMBER + 1)) | |
agvtool new-version -all $(($(app-store-connect get-latest-testflight-build-number "$APP_STORE_APP_ID") + 1)) | |
- name: Set up code signing settings on Xcode project | |
script: | | |
xcode-project use-profiles | |
- name: Build ipa for distribution | |
script: | | |
xcode-project build-ipa --workspace "$FCI_BUILD_DIR/ios/$XCODE_WORKSPACE" --scheme "$XCODE_SCHEME" | |
artifacts: | |
- build/ios/ipa/*.ipa | |
- /tmp/xcodebuild_logs/*.log | |
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app | |
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM | |
publishing: | |
# See the following link for details about email publishing - https://docs.codemagic.io/publishing-yaml/distribution/#email | |
email: | |
recipients: | |
- [email protected] | |
- [email protected] | |
notify: | |
success: true # To not receive a notification when a build succeeds | |
failure: false # To not receive a notification when a build fails | |
slack: | |
# See the following link about how to connect your Slack account - https://docs.codemagic.io/publishing-yaml/distribution/#slack | |
channel: '#channel-name' | |
notify_on_build_start: true # To receive a notification when a build starts | |
notify: | |
success: true # To not receive a notification when a build succeeds | |
failure: false # To not receive a notification when a build fails | |
app_store_connect: | |
apple_id: $APPLE_ID | |
password: $APP_SPECIFIC_PASSWORD |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment