-
Notifications
You must be signed in to change notification settings - Fork 4
254 lines (207 loc) · 7.72 KB
/
app-deploy.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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
name: Deploy app
on:
push:
branches:
- test
workflow_dispatch:
inputs:
deploy_target:
description: "Deploy to:"
required: true
default: "fad"
type: choice
options:
- "fad"
- "store"
- "ios_fad"
- "ios_store"
- "android_fad"
- "android_store"
jobs:
setup:
runs-on: ubuntu-latest
outputs:
build_number: ${{ steps.get_build_number.outputs.build_number }}
flutter_version: ${{ steps.set_output.outputs.flutter_version }}
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
FLUTTER_VERSION: '3.24.0'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Check deploy target and branch
run: |
if [[ "${{ github.ref }}" != "refs/heads/main" &&
( "${{ inputs.deploy_target }}" == "store" ||
"${{ inputs.deploy_target }}" == "ios_store" ||
"${{ inputs.deploy_target }}" == "android_store" ) ]]; then
echo "🚫 Error: Deployment to store, ios_store, or android_store is only allowed from the 'main' branch."
exit 1
fi
- name: Set output for flutter_version
id: set_output
run: |
echo "flutter_version=${FLUTTER_VERSION}" >> $GITHUB_OUTPUT
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
- name: Install Dart dependencies
run: dart pub get
- uses: bluefireteam/melos-action@v3
# Secrets
- name: Decrypt secrets
run: melos decrypt-secrets
- name: Get build number
id: get_build_number
run: |
BUILD_NUMBER=$(bash scripts/get-build-number.sh)
if [ -z "$BUILD_NUMBER" ]; then
echo "Error: Build number is not specified."
exit 1
fi
echo "#️⃣ New build number: $BUILD_NUMBER"
echo "build_number=$BUILD_NUMBER" >> $GITHUB_OUTPUT
- name: Check Flutter Path
run: echo "Flutter path is = $FLUTTER_ROOT"
- name: Remove Flutter
run: |
rm -rf $FLUTTER_ROOT
echo "Flutter removed to free up space"
- name: Clean Dart dependencies
run: |
rm -rf .dart_tool/
rm -rf $HOME/.pub-cache/
# iOS deploy
ios-deploy:
needs: setup
runs-on: macos-latest
if: ${{ inputs.deploy_target == '' || inputs.deploy_target == 'fad' || inputs.deploy_target == 'store' || inputs.deploy_target == 'ios_fad' || inputs.deploy_target == 'ios_store' }}
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set target variable based on deploy_target
run: |
echo "deploy_target is = ${{ inputs.deploy_target }}"
if [[ "${{ inputs.deploy_target }}" == "" || "${{ inputs.deploy_target }}" == "fad" || "${{ inputs.deploy_target }}" = "ios_fad" ]]; then
echo "ios_target=ios_fad" >> $GITHUB_ENV
elif [[ "${{ inputs.deploy_target }}" == "store" || "${{ inputs.deploy_target }}" == "ios_store" ]]; then
echo "ios_target=ios_store" >> $GITHUB_ENV
fi
- name: Display ios_target value
run: echo "ios_target is set to = ${{ env.ios_target }}"
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.setup.outputs.flutter_version }}
channel: 'stable'
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
- name: Display Flutter version
run: flutter --version
- uses: bluefireteam/melos-action@v3
# Secrets
- name: Decrypt secrets
run: melos decrypt-secrets
# iOS certs
- name: Making sure the iOS certificates and profiles are installed
run: melos build:ios_match_assure
# Dart/Flutter
- name: Generate dart code
run: melos codegen --no-select
- name: Display Build Number
run:
echo "Number is = ${{ needs.setup.outputs.build_number }}"
- name: Build and deploy
run: |
bash scripts/build.sh \
--deploy-target ${{ env.ios_target }} \
--build-number ${{ needs.setup.outputs.build_number }} \
--upload true
- name: Clean Xcode Derived Data
run: |
rm -rf ~/Library/Developer/Xcode/DerivedData
- name: Clean CocoaPods cache
run: |
pod cache clean --all
rm -rf ios/Pods
rm -rf ios/Podfile.lock
- name: Remove Flutter
run: |
rm -rf $FLUTTER_ROOT
- name: Clean Dart dependencies
run: |
rm -rf .dart_tool/
rm -rf $HOME/.pub-cache/
# Android deploy
android-deploy:
needs: setup
runs-on: ubuntu-latest
if: ${{ inputs.deploy_target == '' || inputs.deploy_target == 'fad' || inputs.deploy_target == 'store' || inputs.deploy_target == 'android_fad' || inputs.deploy_target == 'android_store' }}
env:
SECRET_PASSPHRASE: ${{ secrets.SECRET_PASSPHRASE }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
steps:
- name: Reinstall existing fastlane plugin
run: |
sudo gem uninstall fastlane-plugin-firebase_app_distribution
gem install fastlane-plugin-firebase_app_distribution --user-install
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Set target variable based on deploy_target
run: |
echo "deploy_target is = ${{ inputs.deploy_target }}"
if [[ "${{ inputs.deploy_target }}" == "" || "${{ inputs.deploy_target }}" == "fad" || "${{ inputs.deploy_target }}" = "android_fad" ]]; then
echo "android_target=android_fad" >> $GITHUB_ENV
elif [[ "${{ inputs.deploy_target }}" == "store" || "${{ inputs.deploy_target }}" == "android_store" ]]; then
echo "android_target=android_store" >> $GITHUB_ENV
fi
- name: Display android_target value
run: echo "android_target is set to = ${{ env.android_target }}"
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ needs.setup.outputs.flutter_version }}
channel: 'stable'
cache: true
cache-key: flutter-:os:-:channel:-:version:-:arch:-:hash:-${{ hashFiles('**/pubspec.lock') }}
- name: Display Flutter version
run: flutter --version
- uses: bluefireteam/melos-action@v3
- uses: actions/setup-java@v4
with:
distribution: zulu
java-version: "17.x"
# Secrets
- name: Decrypt secrets
run: melos decrypt-secrets
# Dart/Flutter
- name: Generate dart code
run: melos codegen --no-select
- name: Display Build Number
run:
echo "Number is = ${{ needs.setup.outputs.build_number }}"
- name: Build and deploy
run: |
bash scripts/build.sh \
--deploy-target ${{ env.android_target }} \
--build-number ${{ needs.setup.outputs.build_number }} \
--upload true
- name: Remove Flutter
run: |
rm -rf $FLUTTER_ROOT
echo "Flutter removed to free up space"
- name: Clean Dart dependencies
run: |
rm -rf .dart_tool/
rm -rf $HOME/.pub-cache/