-
Notifications
You must be signed in to change notification settings - Fork 2
/
codemagic.yaml
221 lines (204 loc) · 7.53 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
workflows:
alpha-release-workflow: &base
name: Alpha release workflow
max_build_duration: 30
instance_type: mac_mini_m1
environment:
android_signing:
- Graded
ios_signing:
distribution_type: app_store
bundle_identifier: com.NightDreamGames.Gradely
groups:
- gh-auth
- playstore-auth
vars:
PACKAGE_NAME: "com.NightDreamGames.Grade.ly"
APP_ID: 6444681284
xcode: latest
java: 17
cocoapods: default
integrations:
app_store_connect: NightDream Games
scripts:
- name: Bump Flutter submodule
working_directory: .flutter/
script: |
git pull
bin/flutter --version
- name: Get Flutter packages
script: |
.flutter/bin/flutter pub get
- name: Flutter analyze
script: |
.flutter/bin/flutter analyze
- name: Flutter unit tests
script: |
.flutter/bin/flutter test
- name: Set up local.properties
script: |
echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
- name: Build AAB
script: |
.flutter/bin/flutter build appbundle --release \
--build-number=$(($PROJECT_BUILD_NUMBER + 50))
- name: Set up code signing settings on Xcode project
script: |
xcode-project use-profiles --project="ios/**/*.xcodeproj"
- name: Install pods
script: |
find . -name "Podfile" -execdir pod install \;
- name: Build IPA
script: |
.flutter/bin/flutter build ipa --release \
--build-number=$(($PROJECT_BUILD_NUMBER + 50)) \
--export-options-plist=/Users/builder/export_options.plist
artifacts:
- build/**/outputs/**/*.aab
- build/**/outputs/**/apk/release/*.apk
- build/**/outputs/**/mapping.txt
- build/ios/ipa/*.ipa
- /tmp/xcodebuild_logs/*.log
publishing: &base_publishing
email:
recipients:
- build@nightdreamgames.com
notify:
success: false
failure: true
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
release_promotion:
track: alpha
app_store_connect:
auth: integration
submit_to_testflight: true
beta_groups:
- External testers
submit_to_app_store: false
cache:
cache_paths:
- $FLUTTER_ROOT/.pub-cache
- $HOME/Library/Caches/CocoaPods
production-release-workflow:
<<: *base
name: Production release workflow
scripts:
- name: Bump Flutter submodule
working_directory: .flutter/
script: |
git pull
bin/flutter --version
- name: Set up environment variables
script: |
file=$(cat pubspec.yaml)
fullVersion=$(echo | grep -i -e "version: " pubspec.yaml)
echo "BUILD_NAME=$(echo $fullVersion | cut -d " " -f 2 | cut -d "+" -f 1)" >> $CM_ENV
echo "BUILD_NUMBER=$(($PROJECT_BUILD_NUMBER+50))" >> $CM_ENV
echo "$fullVersion BUILD_NAME: ${BUILD_NAME} BUILD_NUMBER: ${BUILD_NUMBER}"
- name: Check version number
script: |
if [ $(git tag -l "$BUILD_NAME") ]; then
echo "Version $BUILD_NAME already exists"
exit 1
fi
- name: Get Flutter packages
script: |
.flutter/bin/flutter pub get
- name: Flutter analyze
script: |
.flutter/bin/flutter analyze
- name: Flutter unit tests
script: |
.flutter/bin/flutter test
- name: Automatic versioning
script: |
perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($ENV{BUILD_NUMBER})/e' pubspec.yaml
changelog_file="CHANGELOG.md"
files=("release_notes_en-GB.txt" "release_notes_fr-FR.txt" "release_notes_de-DE.txt")
CHANGELOG=$(sed -n "/\[$BUILD_NAME\]/,/\[.*\] -/p" $changelog_file | sed '$d' | sed '$d' | sed '$s/\\n$//')
echo "CHANGELOG=$CHANGELOG" >> $CM_ENV
stripped_changelog=$(echo "$CHANGELOG" | sed '1s/^...//; 3s/^....//; $s/\\n$//')
echo -e "$CHANGELOG"
echo -e "$stripped_changelog"
echo "$CHANGELOG" > "fastlane/metadata/android/en-US/changelogs/$BUILD_NUMBER.txt"
if [[ -z "$stripped_changelog" ]]; then
echo "Changelog not found for version $BUILD_NAME."
exit 1
fi
if [ ${#stripped_changelog} -gt 500 ]; then
echo "Changelog length 500 characters."
exit 1
fi
for file in ${files[@]}; do
echo "$stripped_changelog" > ${file}
done
last_release=$(gh release view --json tagName -q '.tagName')
changelog_gh=$CHANGELOG
if [[ -z "$last_release" ]]; then
echo "No previous release found."
else
changelog_gh+=$"\n\n#### Full changelog: https://github.com/NightDreamGames/Graded/compare/${last_release}...${BUILD_NAME}"
fi
echo -e "$changelog_gh" > changelog_gh.txt
echo "$CHANGELOG"
echo
echo "$stripped_changelog"
echo
echo "$changelog_gh"
- name: Commit versioning changes
script: |
gh auth setup-git
git add fastlane/metadata/android
git add pubspec.yaml
git commit -m "Versioning changes for ${BUILD_NAME}"
git push
- name: Set up local.properties
script: |
echo "flutter.sdk=$HOME/programs/flutter" > "$CM_BUILD_DIR/android/local.properties"
- name: Build AAB
script: |
.flutter/bin/flutter build appbundle --release \
--build-number=$BUILD_NUMBER
- name: Build APK
script: |
.flutter/bin/flutter build apk --release \
--build-number=$BUILD_NUMBER
- name: Set up code signing settings on Xcode project
script: |
xcode-project use-profiles --project="ios/**/*.xcodeproj"
- name: Install pods
script: |
find . -name "Podfile" -execdir pod install \;
- name: Build IPA
script: |
.flutter/bin/flutter build ipa --release \
--build-number=$(($PROJECT_BUILD_NUMBER + 50)) \
--export-options-plist=/Users/builder/export_options.plist
- name: Publish to GitHub
script: |
#!/usr/bin/env zsh
cat changelog_gh.txt
mv build/app/outputs/apk/release/app-release.apk build/app/outputs/apk/release/graded-${BUILD_NAME}.apk
mv build/ios/ipa/Graded.ipa build/ios/ipa/graded-${BUILD_NAME}.ipa
gh release create "${BUILD_NAME}" \
--title "${BUILD_NAME}" \
--notes-file changelog_gh.txt \
build/app/outputs/apk/release/graded-${BUILD_NAME}.apk \
build/ios/ipa/graded-${BUILD_NAME}.ipa
publishing:
<<: *base_publishing
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: internal
release_promotion:
track: production
app_store_connect:
auth: integration
submit_to_testflight: true
beta_groups:
- External testers
submit_to_app_store: true
cancel_previous_submissions: true
release_type: AFTER_APPROVAL