-
Notifications
You must be signed in to change notification settings - Fork 6
283 lines (258 loc) · 10.6 KB
/
Copy pathdeploy-develop.yml
File metadata and controls
283 lines (258 loc) · 10.6 KB
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
name: deploy-develop-mobile
run-name: Build and deploy develop build for Android & iOS
on:
pull_request:
branches:
- 'ci/**'
push:
branches:
- "develop"
paths:
- ".github/**"
- "android/**"
- "ios/**"
- "lib/**"
- "pubspec.yaml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
# ==========================================
# ANDROID: Standard APK
# ==========================================
build-default:
name: Build standard app package
runs-on: ubuntu-latest
environment: develop-android
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
submodules: recursive
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
with:
flutter-version: '3.47.1'
channel: 'stable'
cache: true
- name: install java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00
with:
distribution: 'zulu'
java-version: '17'
- name: install ndk
uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410
id: setup-ndk
with:
ndk-version: r27
link-to-sdk: true
local-cache: true
- name: load certificate
uses: mobiledevops/secret-to-file-action@be5f14e82c235ccde011f6ab0f6c984b35dc34c6
with:
base64-encoded-secret: ${{ secrets.APP_CERTIFICATE }}
filename: "keystore.jks"
working-directory: ./android/app
- name: create credentials
env:
keystore_pass: ${{ secrets.KEYSTORE_PASS }}
run: |
echo -e "storePassword: $keystore_pass\nkeyPassword: $keystore_pass\nkeyAlias: upload-unn-mobile\nstoreFile=keystore.jks\n" >> ./android/key.properties
- name: install firebase
run: |
mkdir -p "$HOME/bin"
curl -fsSL -o "$HOME/bin/firebase" https://firebase.tools/bin/linux/latest
chmod +x "$HOME/bin/firebase"
echo "$HOME/bin" >> $GITHUB_PATH
- name: get dependencies
run: flutter pub get
- name: configure flutterfire
env:
firebase_token: ${{ secrets.FIREBASE_TOKEN }}
run: |
dart pub global activate flutterfire_cli 1.3.1
flutterfire configure -t $firebase_token -y -p unn-mobile-1 --platforms=android --android-package-name=ru.bitcodersnn.unnstudenthub
- name: build
run: |
flutter doctor --verbose
flutter build apk --flavor default
mv build/app/outputs/flutter-apk/app-default-release.apk build/unn-mobile-default.apk
sha1sum build/unn-mobile-default.apk > build/unn-mobile-default.apk.sha1
- name: delete old build artifacts
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: unn-mobile-default
- name: upload build artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: unn-mobile-default
path: |
build/unn-mobile-default.apk
build/unn-mobile-default.apk.sha1
# ==========================================
# ANDROID: Google Play AAB
# ==========================================
build-google-play:
name: Build Google Play app package
runs-on: ubuntu-latest
environment: develop-android
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
submodules: recursive
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
with:
flutter-version: '3.47.1'
channel: 'stable'
cache: true
- name: install java
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00
with:
distribution: 'zulu'
java-version: '17'
- name: install ndk
uses: nttld/setup-ndk@afb4c9964b521afb97c864b7d40b11e6911bd410
id: setup-ndk
with:
ndk-version: r27
link-to-sdk: true
local-cache: true
- name: load certificate
uses: mobiledevops/secret-to-file-action@be5f14e82c235ccde011f6ab0f6c984b35dc34c6
with:
base64-encoded-secret: ${{ secrets.APP_CERTIFICATE }}
filename: "keystore.jks"
working-directory: ./android/app
- name: create credentials
env:
keystore_pass: ${{ secrets.KEYSTORE_PASS }}
run: |
echo -e "storePassword: $keystore_pass\nkeyPassword: $keystore_pass\nkeyAlias: upload-unn-mobile\nstoreFile=keystore.jks\n" >> ./android/key.properties
- name: install firebase
run: |
mkdir -p "$HOME/bin"
curl -fsSL -o "$HOME/bin/firebase" https://firebase.tools/bin/linux/latest
chmod +x "$HOME/bin/firebase"
echo "$HOME/bin" >> $GITHUB_PATH
- name: get dependencies
run: flutter pub get
- name: configure flutterfire
env:
firebase_token: ${{ secrets.FIREBASE_TOKEN }}
run: |
dart pub global activate flutterfire_cli 1.3.1
flutterfire configure -t $firebase_token -y -p unn-mobile-1 --platforms=android --android-package-name=ru.bitcodersnn.unnstudenthub
- name: build
run: |
flutter doctor --verbose
flutter build appbundle --flavor GooglePlay
- name: delete old build artifact
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: unn-mobile-googleplay
- name: upload build artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: unn-mobile-googleplay
path: "build/app/outputs/bundle/GooglePlayRelease/app-GooglePlay-release.aab"
# ==========================================
# iOS: Unsigned IPA + dSYM
# ==========================================
build-ios:
name: Build iOS app package (no codesign)
runs-on: macos-latest
environment: develop-ios
outputs:
ipa_filename: ${{ steps.pack_ipa.outputs.ipa_filename }}
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
with:
submodules: recursive
- uses: subosito/flutter-action@fd55f4c5af5b953cc57a2be44cb082c8f6635e8e
with:
flutter-version: '3.47.1'
channel: 'stable'
cache: true
- name: get dependencies
run: flutter pub get
- name: install firebase
run: |
mkdir -p "$HOME/bin"
curl -fsSL -o "$HOME/bin/firebase" https://firebase.tools/bin/macos/latest
chmod +x "$HOME/bin/firebase"
echo "$HOME/bin" >> $GITHUB_PATH
- name: configure flutterfire (iOS)
env:
firebase_token: ${{ secrets.FIREBASE_TOKEN }}
run: |
dart pub global activate flutterfire_cli
flutterfire configure \
--token=$firebase_token \
--yes \
--project=unn-mobile-1 \
--platforms=ios \
- name: Fix Crashlytics SPM CI bug
run: |
sed -i '' 's|\${DERIVED_DATA_PATH}/SourcePackages|\${SRCROOT}/../build/ios/SourcePackages|g' ios/Runner.xcodeproj/project.pbxproj
- name: build ios (no codesign)
run: |
flutter doctor --verbose
flutter build ipa --no-codesign
- name: Pack IPA
id: pack_ipa
run: |
INFO_PLIST="build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app/Info.plist"
APP_NAME=$(/usr/libexec/PlistBuddy -c "Print :CFBundleDisplayName" "$INFO_PLIST" 2>/dev/null || /usr/libexec/PlistBuddy -c "Print :CFBundleName" "$INFO_PLIST")
SAFE_APP_NAME=$(echo "$APP_NAME" | tr ' ' '-' | tr -cd '[:alnum:]-_.')
VERSION=$(/usr/libexec/PlistBuddy -c "Print :CFBundleShortVersionString" "$INFO_PLIST")
BUILD=$(/usr/libexec/PlistBuddy -c "Print :CFBundleVersion" "$INFO_PLIST")
IPA_FILENAME="${SAFE_APP_NAME}-${VERSION}-${BUILD}.ipa"
echo "Формируем IPA с именем: $IPA_FILENAME"
echo "ipa_filename=$IPA_FILENAME" >> $GITHUB_OUTPUT
mkdir -p Payload
cp -r build/ios/archive/Runner.xcarchive/Products/Applications/Runner.app Payload/
zip -r "$IPA_FILENAME" Payload
rm -rf Payload
- name: delete old iOS artifact
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b
with:
name: unn-mobile-ios
- name: Upload IPA Artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
with:
name: unn-mobile-ios
path: ${{ steps.pack_ipa.outputs.ipa_filename }}
# ==========================================
# DEPLOY: Firebase App Distribution
# ==========================================
deploy:
runs-on: ubuntu-latest
environment: develop-android
needs: [build-google-play, build-ios]
steps:
- uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955
- name: retrieve Android binary
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
name: unn-mobile-googleplay
- name: retrieve iOS binary
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
with:
name: unn-mobile-ios
- name: install firebase
run: curl -sL https://firebase.tools | bash
# --- Android Deploy ---
- name: deploy android (main)
if: github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main'
env:
firebase_token: ${{ secrets.FIREBASE_TOKEN }}
app_id: ${{ secrets.FIREBASE_A_APP_ID }}
run: |
firebase --project unn-mobile-1 --token $firebase_token appdistribution:distribute --groups "testers" --app "$app_id" --release-notes "$(git log -1 --pretty=%B)" "${GITHUB_WORKSPACE}/app-GooglePlay-release.aab"
- name: deploy android (PR)
if: github.ref != 'refs/heads/develop' && github.ref != 'refs/heads/main'
env:
TITLE: ${{ github.head_ref || github.ref_name }}
firebase_token: ${{ secrets.FIREBASE_TOKEN }}
app_id: ${{ secrets.FIREBASE_A_APP_ID }}
run: |
firebase --project unn-mobile-1 --token $firebase_token appdistribution:distribute --groups "testers" --app "$app_id" --release-notes "$TITLE" "${GITHUB_WORKSPACE}/app-GooglePlay-release.aab"