-
Notifications
You must be signed in to change notification settings - Fork 2
/
codemagic.yaml
84 lines (83 loc) · 2.77 KB
/
codemagic.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
scripts:
- &install_npm_dependencies
name: Install npm dependencies
script: cd .. && npm install && npm run install:shared && npm run build:shared && npm run install:mobile
- &set_android_sdk
name: Set Android SDK location
script: echo "sdk.dir=$ANDROID_SDK_ROOT" > "$FCI_BUILD_DIR/mobile/android/local.properties"
- &set_up_keys
name: Set up keystore
script: |
echo $FCI_BUILD_DIR
echo $CM_KEYSTORE | base64 --decode > "$FCI_BUILD_DIR/mobile/android/app/$CM_KEYSTORE_PATH"
cat >> "$FCI_BUILD_DIR/mobile/android/keystore.properties" << EOF
storePassword=$CM_KEYSTORE_PASSWORD
keyPassword=$CM_KEY_ALIAS_PASSWORD
keyAlias=$CM_KEY_ALIAS
storeFile=$CM_KEYSTORE_PATH
EOF
- &set-env-vars
name: Create .env file and set variables
script: |
cat >> .env << EOF
API_ORIGIN_URL = $API_ORIGIN_URL
APP_HOST = $APP_HOST
APP_SCHEME = $APP_SCHEME
STRIPE_PUBLIC_KEY = $STRIPE_PUBLIC_KEY
EOF
- &set_up_android_updated_versions
name: Set up updated build number and provide correct versioning
script: |
LATEST_GOOGLE_PLAY_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks=internal)
if [ -z LATEST_BUILD_NUMBER ]; then
UPDATED_BUILD_NUMBER=$BUILD_NUMBER
else
UPDATED_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_BUILD_NUMBER + 1))
fi
echo $UPDATED_BUILD_NUMBER > "$FCI_BUILD_DIR/mobile/android/app/versionCode"
VERSION_NAME_PATH=$FCI_BUILD_DIR/mobile/android/app/versionName
UPDATED_VERSION_NAME=$(cat $VERSION_NAME_PATH | awk -F. -v PATCH_NUMBER=$UPDATED_BUILD_NUMBER -v OFS=. '{$NF = PATCH_NUMBER ; print}')
echo $UPDATED_VERSION_NAME > $VERSION_NAME_PATH
workflows:
react-native-android:
name: React Native Android App
working_directory: mobile
max_build_duration: 120
instance_type: mac_mini_m1
environment:
node: 16.15.0
npm: 8.11.0
groups:
- keystore_credentials
- env_vars
- google_play
vars:
PACKAGE_NAME: 'com.guruhub'
triggering:
events:
- push
branch_patterns:
- pattern: development
include: true
source: true
cancel_previous_builds: true
when:
changeset:
includes:
- 'mobile/'
scripts:
- *install_npm_dependencies
- *set_android_sdk
- *set_up_keys
- *set-env-vars
- *set_up_android_updated_versions
- name: Build Android release
script: |
cd android && ./gradlew clean bundleRelease
artifacts:
- android/app/build/outputs/**/*.aab
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
submit_as_draft: true