forked from NightDreamGames/Graded
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codemagic.yaml
192 lines (184 loc) · 6.51 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
workflows:
base-workflow: &base
name: Base Workflow
max_build_duration: 30
instance_type: mac_mini_m1
environment: &base_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
cocoapods: default
integrations:
app_store_connect: NightDream Games
scripts: &base_scripts
- name: Bump Flutter submodule
working_directory: .flutter/
script: |
git pull origin stable
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:
notify:
success: false
failure: true
cache:
cache_paths:
- $FLUTTER_ROOT/.pub-cache
- $HOME/Library/Caches/CocoaPods
release-workflow:
<<: *base
name: Release Workflow
scripts:
- name: Bump Flutter submodule
working_directory: .flutter/
script: |
git pull origin stable
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')
if [[ -z "$changelog" ]]; then
echo "Changelog not found for version $BUILD_NAME."
exit 1
fi
for file in ${files[@]}; do
{ echo "$changelog"; } >${file}
cat $file
echo; echo
done
cp release_notes_en-GB.txt fastlane/metadata/android/en-US/changelogs/$BUILD_NUMBER.txt
- name: Commit versioning changes
script: |
gh auth setup-git
git add --all
git reset HEAD -- release_notes_en-GB.txt
git reset HEAD -- release_notes_fr-FR.txt
git reset HEAD -- release_notes_de-DE.txt
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
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 release_notes_en-GB.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: production
submit_as_draft: false
app_store_connect:
auth: integration
submit_to_testflight: false
submit_to_app_store: true
cancel_previous_submissions: true
release_type: AFTER_APPROVAL
internal-workflow:
<<: *base
name: Internal Workflow
publishing:
<<: *base_publishing
google_play:
credentials: $GCLOUD_SERVICE_ACCOUNT_CREDENTIALS
track: "internal"
submit_as_draft: false
app_store_connect:
auth: integration
submit_to_testflight: false
submit_to_app_store: false