-
Notifications
You must be signed in to change notification settings - Fork 58
/
codemagic.yaml
236 lines (231 loc) · 6.76 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
definitions:
base: &base
max_build_duration: 120
working_directory: apps/native/app
when:
changeset:
includes:
- 'apps/native/app'
# To save on build minutes, workflows are currently triggered manually and/or once per day.
# default_triggers: &default_triggers
# events:
# - push
# branch_patterns:
# - pattern: "main"
# include: true
# source: true
shared_envs: &shared_envs
XCODE_WORKSPACE: 'IslandApp.xcworkspace'
CM_CLONE_DEPTH: 200
NODE_OPTIONS: '--max-old-space-size=8192'
scripts:
- &check_changes
name: Check changes since last build
working_directory: .
script: |
set -e
echo "Considering changes between $CM_PREVIOUS_COMMIT and $CM_COMMIT"
if git cat-file -e "$CM_PREVIOUS_COMMIT"^{commit} >& /dev/null; then
notes=$(git log --pretty=format:"%s (%an)" "$CM_PREVIOUS_COMMIT".."$CM_COMMIT" -- codemagic.yaml apps/native/app)
if [[ $notes == "" ]]; then
echo "No changes detected in native app. Exiting."
exit 1
else
echo "App changes since last build:"
echo "$notes" | tee apps/native/app/release_notes_en-US.txt
fi
else
echo "No previous commit detected. Continuing."
fi
- &set_android_location
name: Prepare Android configuration
script: |
echo "sdk.dir=$ANDROID_SDK_ROOT" > android/local.properties
echo $ANDROID_FIREBASE_SECRET > android/app/google-services.json
- &npm_install
name: Install npm dependencies
working_directory: .
script: |
corepack enable
corepack prepare
yarn install --immutable
- &codegen
name: Run codegen
working_directory: .
script: |
yarn codegen
- &cocoapods
name: Install CocoaPods dependencies
script: |
cd ios && pod install
- &provisioning_profiles
name: Set up provisioning profiles settings on Xcode project
script: xcode-project use-profiles
- &increment_build_number
name: Increment build number
script: |
cd ios
LATEST_BUILD_NUMBER=$(app-store-connect get-latest-build-number "$APP_STORE_APPLE_ID")
agvtool new-version -all $(($LATEST_BUILD_NUMBER + 1))
- &build_ipa
name: Build ipa for distribution
script: |
xcode-project build-ipa \
--workspace "ios/$XCODE_WORKSPACE" \
--scheme "$XCODE_SCHEME"
- &build_android
name: Build Android release
script: |
LATEST_GOOGLE_PLAY_BUILD_NUMBER=$(google-play get-latest-build-number --package-name "$PACKAGE_NAME")
if [ -z $LATEST_GOOGLE_PLAY_BUILD_NUMBER ]; then
exit 1
else
UPDATED_BUILD_NUMBER=$(($LATEST_GOOGLE_PLAY_BUILD_NUMBER + 1))
fi
cd android
./gradlew bundle${ANDROID_APP}Release -PversionCode=$UPDATED_BUILD_NUMBER
publishing:
ios_publishing: &ios_publishing
app_store_connect:
auth: integration
submit_to_testflight: false
submit_to_app_store: false
android_publishing: &android_publishing
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
slack_errors: &slack_errors
slack:
channel: '#team-app-builds'
notify:
# don't want to spam slack with 4 successful builds. Overridden in dev-app-ios.
success: false
failure: true
workflows:
prod-app-ios:
<<: *base
name: Island.is Prod App iOS
instance_type: mac_mini_m1
cache: &ios_cache
cache_paths:
- ~/Library/Caches/CocoaPods
- $CM_BUILD_DIR/.yarn/cache
- $CM_BUILD_DIR/.cache/nx
integrations:
app_store_connect: 'Island.is API Key'
environment:
ios_signing:
distribution_type: app_store
bundle_identifier: is.island.app
vars:
<<: *shared_envs
BUNDLE_ID: 'is.island.app'
XCODE_SCHEME: 'Ísland.is'
APP_STORE_APPLE_ID: 1569828682
scripts:
- *check_changes
- *npm_install
- *codegen
- *cocoapods
- *provisioning_profiles
- *increment_build_number
- *build_ipa
artifacts: &ios_artifacts
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.app
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
publishing:
<<: *ios_publishing
<<: *slack_errors
dev-app-ios:
<<: *base
name: Island.is Dev App iOS
instance_type: mac_mini_m1
cache: *ios_cache
integrations:
app_store_connect: 'Island.is API Key'
environment:
ios_signing:
distribution_type: app_store
bundle_identifier: is.island.app.dev
vars:
<<: *shared_envs
BUNDLE_ID: 'is.island.app.dev'
XCODE_SCHEME: 'Ísland.dev'
APP_STORE_APPLE_ID: 1570427360
scripts:
- *check_changes
- *npm_install
- *codegen
- *cocoapods
- *provisioning_profiles
- *increment_build_number
- *build_ipa
artifacts: *ios_artifacts
publishing:
<<: *ios_publishing
slack:
channel: '#team-app-builds'
notify:
success: true
failure: true
prod-app-android:
<<: *base
name: Island.is Prod App Android
instance_type: mac_mini_m1
## Switch when we have billing
# instance_type: linux_x2
cache: &android_cache
cache_paths:
- ~/.gradle/caches
- $CM_BUILD_DIR/.yarn/cache
- $CM_BUILD_DIR/.cache/nx
environment:
android_signing:
- island-upload-keystore
groups:
- google_credentials
- firebase_credentials
vars:
<<: *shared_envs
PACKAGE_NAME: 'is.island.app'
ANDROID_APP: prod
scripts:
- *check_changes
- *set_android_location
- *npm_install
- *codegen
- *build_android
artifacts: &android_artifacts
- android/app/build/outputs/**/*.aab
publishing:
<<: *android_publishing
<<: *slack_errors
dev-app-android:
<<: *base
name: Island.is Dev App Android
instance_type: mac_mini_m1
## Switch when we have billing
# instance_type: linux_x2
cache: *android_cache
environment:
android_signing:
- island-upload-keystore
groups:
- google_credentials
- firebase_credentials
vars:
<<: *shared_envs
PACKAGE_NAME: 'is.island.app.dev'
ANDROID_APP: dev
scripts:
- *check_changes
- *set_android_location
- *npm_install
- *codegen
- *build_android
artifacts: *android_artifacts
publishing:
<<: *android_publishing
<<: *slack_errors