-
Notifications
You must be signed in to change notification settings - Fork 1
/
codemagic.yaml
215 lines (181 loc) · 8.88 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
definitions:
env_vars: &env_vars
S3_BUCKET_NAME: cmwhitelabel # The name of your S3 bucket that have all of your clients assets.
ANDROID_ASSETS_FOLDER: res # The name of your folder in S3 bucket that have the client's Android assets from (/android/app/src/main/res/).
IOS_ASSETS_FOLDER: AppIcon.appiconset # The name of your folder in S3 bucket that have the client's iOS assets from (/ios/Runner/Assets.xcassets/).
scripts:
- &get_assets
name: Get assets from AWS S3 bucket
script: |
ASSETS_FOLDER=assets_${CLIENT_ID}
echo "ASSETS_FOLDER=$ASSETS_FOLDER" >> $CM_ENV
aws s3 cp s3://$S3_BUCKET_NAME/$ASSETS_FOLDER.zip $ASSETS_FOLDER.zip
unzip $ASSETS_FOLDER.zip -d $ASSETS_FOLDER
# Builds will be triggered via Codemagic's REST API with the
# $CLIENT_ID variable and the WL_CLIENT_ID environment group
# in the payload
workflows:
ios-client-release:
name: iOS client release
instance_type: mac_mini_m2
labels:
- ${CLIENT_ID} # Helpful when you open your Codemagic's builds page
environment:
groups:
# customer specific groups are set using the API request
- aws_credentials # Includes (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION)
vars:
<<: *env_vars
XCODE_SCHEME: "Runner"
scripts:
- *get_assets #Getting client assets from S3 bucket
- name: Change iOS app name
script: /usr/libexec/PlistBuddy -c "Set :CFBundleName $APP_NAME" -c "Set :CFBundleDisplayName $APP_NAME" ios/${XCODE_SCHEME}/Info.plist
- name: Set bundle id
script: sed -i '' -e 's/PRODUCT_BUNDLE_IDENTIFIER \= [^\;]*\;/PRODUCT_BUNDLE_IDENTIFIER = '${BUNDLE_ID}';/' ios/${XCODE_SCHEME}.xcodeproj/project.pbxproj
- name: Change iOS icons
script: cp -r ./$ASSETS_FOLDER/$IOS_ASSETS_FOLDER ios/${XCODE_SCHEME}/Assets.xcassets/
- name: Change fonts
script: |
if [ "$FONT_FAMILY" != "Montserrat" ]; then
cp -r "./$ASSETS_FOLDER/$FONT_FAMILY" "./fonts/$FONT_FAMILY"
sed -i '' "s/Montserrat/$FONT_FAMILY/g" pubspec.yaml
fi
# - name: Set client .env file
# script: echo $DOTENV | base64 --decode > assets/client.env
- name: Set main image
script: cp -r ./$ASSETS_FOLDER/header.png assets/header.png
- name: Add settings to assets
script: cp -r ./$ASSETS_FOLDER/settings.json assets/settings.json
- name: Install pods
script: find . -name "Podfile" -execdir pod install \;
- name: iOS code signing
script: |
keychain initialize
app-store-connect fetch-signing-files "$BUNDLE_ID" --type IOS_APP_STORE --create
keychain add-certificates
xcode-project use-profiles
- name: Install dependencies
script: flutter packages pub get
- name: Flutter build ipa and automatic versioning
script: |
BUILD_NUMBER=$(($(app-store-connect get-latest-testflight-build-number "$APP_STORE_ID") + 1))
flutter build ipa --release \
--build-name=1.0.$BUILD_NUMBER \
--build-number=$BUILD_NUMBER \
--dart-define-from-file=$CM_BUILD_DIR/assets/settings.json \
--export-options-plist=/Users/builder/export_options.plist
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- test-results/flutter.json
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
publishing:
app_store_connect: # https://docs.codemagic.io/publishing-yaml/distribution
api_key: $APP_STORE_CONNECT_PRIVATE_KEY # Contents of the API key, can also reference environment variable such as $APP_STORE_CONNECT_PRIVATE_KEY
key_id: $APP_STORE_CONNECT_KEY_IDENTIFIER # Alphanumeric value that identifies the API key, can also reference environment variable such as $APP_STORE_CONNECT_KEY_IDENTIFIER
issuer_id: $APP_STORE_CONNECT_ISSUER_ID # Alphanumeric value that identifies who created the API key, can also reference environment variable such as $APP_STORE_CONNECT_ISSUER_ID
# email:
# recipients:
# - user1@example.com
ios-client-develop:
name: iOS client develop
instance_type: mac_mini_m2
labels:
- ${CLIENT_ID} # Helpful when you open your Codemagic's builds page
environment:
groups:
# customer specific groups are set using the API request
- aws_credentials # Includes (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION)
vars:
<<: *env_vars
XCODE_SCHEME: "Runner"
scripts:
- *get_assets #Getting client assets from S3 bucket
- name: Change iOS app name
script: /usr/libexec/PlistBuddy -c "Set :CFBundleName $APP_NAME" -c "Set :CFBundleDisplayName $APP_NAME" ios/${XCODE_SCHEME}/Info.plist
- name: Set bundle id
script: sed -i '' -e 's/PRODUCT_BUNDLE_IDENTIFIER \= [^\;]*\;/PRODUCT_BUNDLE_IDENTIFIER = '${BUNDLE_ID}';/' ios/${XCODE_SCHEME}.xcodeproj/project.pbxproj
- name: Change iOS icons
script: cp -r ./$ASSETS_FOLDER/$IOS_ASSETS_FOLDER ios/${XCODE_SCHEME}/Assets.xcassets/
- name: Change fonts
script: |
if [ "$FONT_FAMILY" != "Montserrat" ]; then
cp -r "./$ASSETS_FOLDER/$FONT_FAMILY" "./fonts/$FONT_FAMILY"
sed -i '' "s/Montserrat/$FONT_FAMILY/g" pubspec.yaml
fi
# - name: Set client .env file
# script: echo $DOTENV | base64 --decode > assets/client.env
- name: Set main image
script: cp -r ./$ASSETS_FOLDER/header.png assets/header.png
- name: Add settings to assets
script: cp -r ./$ASSETS_FOLDER/settings.json assets/settings.json
- name: Install pods
script: find . -name "Podfile" -execdir pod install \;
- name: iOS code signing
script: |
keychain initialize
app-store-connect fetch-signing-files "$BUNDLE_ID" --type IOS_APP_ADHOC --create
keychain add-certificates
xcode-project use-profiles
- name: Install dependencies
script: flutter packages pub get
- name: Flutter build ipa and automatic versioning
script: |
BUILD_NUMBER=$(($(app-store-connect get-latest-testflight-build-number "$APP_STORE_ID") + 1))
flutter build ipa --release \
--build-name=1.0.$BUILD_NUMBER \
--build-number=$BUILD_NUMBER \
--dart-define-from-file=$CM_BUILD_DIR/assets/settings.json \
--export-options-plist=/Users/builder/export_options.plist
artifacts:
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
- test-results/flutter.json
- $HOME/Library/Developer/Xcode/DerivedData/**/Build/**/*.dSYM
# MARK: Android Workflow
android-client-release:
name: Android client release
instance_type: mac_mini_m1
labels:
- ${CLIENT_ID} # Helpful when you open your Codemagic's builds page
environment:
groups:
- aws_credentials
# Includes (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_DEFAULT_REGION)
vars:
<<: *env_vars
scripts:
- *get_assets #Getting client assets from S3 bucket
- name: Set up keystore
script: echo $CM_KEYSTORE | base64 --decode > $CM_KEYSTORE_PATH
- name: Change Android app name
script: sed -i.bak "s/android:label=.*/android:label=\"$APP_NAME\"/g" android/app/src/main/AndroidManifest.xml
- name: Change Android package name
script: |
echo "android { defaultConfig { applicationId '${PACKAGE_NAME}' } }" > android/changePackage.gradle
echo "apply from: rootProject.file('changePackage.gradle')" >> android/app/build.gradle
- name: Change Android icons
script: cp -r ./$ASSETS_FOLDER/$ANDROID_ASSETS_FOLDER/* ./android/app/src/main/res
- name: Set client .env file
script: echo $DOTENV | base64 --decode > assets/client.env
- name: Set main image # An image that being used in this sample project
script: cp -r ./$ASSETS_FOLDER/hero.png assets/hero.png
- name: Install dependencies
script: flutter packages pub get
- name: Flutter build aab and automatic versioning
script: |
BUILD_NUMBER=$(($(google-play get-latest-build-number --package-name "$PACKAGE_NAME" --tracks="$GOOGLE_PLAY_TRACK") + 1))
flutter build appbundle --release \
--build-name=1.0.$BUILD_NUMBER \
--build-number=$BUILD_NUMBER
artifacts:
- build/**/outputs/**/*.aab
- test-results/flutter.json
publishing:
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
email:
recipients:
- name@mail.com