-
-
Notifications
You must be signed in to change notification settings - Fork 0
346 lines (298 loc) · 13 KB
/
release.yml
File metadata and controls
346 lines (298 loc) · 13 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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
deploy_play_store:
description: "Deploy AAB to Google Play internal track"
type: boolean
default: true
deploy_web:
description: "Deploy web build to Firebase Hosting"
type: boolean
default: true
# Cancel previous runs on the same ref so we don't waste minutes.
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: true
env:
FLUTTER_VERSION: "3.38.2" # keep in sync with your local SDK
JAVA_VERSION: "17"
jobs:
# ──────────────────────────────────────────────
# 0. Unit, widget, and integration tests (web Chrome)
# ──────────────────────────────────────────────
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
- name: Run unit and widget tests
run: flutter test
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
- name: Install ChromeDriver
uses: nanasess/setup-chromedriver@v2
- name: Start ChromeDriver
run: |
chromedriver --port=4444 &
sleep 3
- name: Run integration tests (web)
run: |
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/app_test.dart \
-d web-server \
--release \
--web-browser-flag=--no-sandbox \
--web-browser-flag=--disable-dev-shm-usage
# ──────────────────────────────────────────────
# 0b. Online integration tests (local Supabase + web Chrome)
# ──────────────────────────────────────────────
test-online:
name: Online Tests
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
- name: Set up Supabase CLI
uses: supabase/setup-cli@v1
with:
version: latest
- name: Start local Supabase
run: supabase start
- name: Reset database (migrations + seed)
run: supabase db reset
- name: Wait for Supabase API
run: |
API_URL=$(supabase status --output json | jq -r '.API_URL')
for i in $(seq 1 30); do
code=$(curl -s -o /dev/null -w "%{http_code}" "$API_URL/rest/v1/" || true)
if [ "$code" = "200" ] || [ "$code" = "401" ] || [ "$code" = "404" ]; then
echo "Supabase API ready (HTTP $code)"
break
fi
echo "Waiting for Supabase API... ($i/30)"
sleep 2
done
- name: Extract Supabase credentials
id: supabase
run: |
echo "url=$(supabase status --output json | jq -r '.API_URL')" >> "$GITHUB_OUTPUT"
echo "anon_key=$(supabase status --output json | jq -r '.ANON_KEY')" >> "$GITHUB_OUTPUT"
- name: Install Chrome
uses: browser-actions/setup-chrome@v1
- name: Install ChromeDriver
uses: nanasess/setup-chromedriver@v2
- name: Start ChromeDriver
run: |
chromedriver --port=4444 &
sleep 3
- name: Run online integration tests (web)
run: |
flutter drive \
--driver=test_driver/integration_test.dart \
--target=integration_test/online_app_test.dart \
-d web-server \
--release \
--dart-define=SUPABASE_URL=${{ steps.supabase.outputs.url }} \
--dart-define=SUPABASE_ANON_KEY=${{ steps.supabase.outputs.anon_key }} \
--web-browser-flag=--no-sandbox \
--web-browser-flag=--disable-dev-shm-usage
- name: Stop local Supabase
if: always()
run: supabase stop
# ──────────────────────────────────────────────
# 1. Build Android APK + AAB
# ──────────────────────────────────────────────
build-android:
name: Build Android
needs: [test]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: ${{ env.JAVA_VERSION }}
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
# Decode the release keystore from a base64 secret.
- name: Decode keystore
run: |
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/release-keystore.jks
# Write key.properties so build.gradle.kts picks it up.
- name: Create key.properties
env:
STORE_FILE: ${{ github.workspace }}/android/app/release-keystore.jks
STORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
KEY_ALIAS_VAL: ${{ secrets.KEY_ALIAS }}
KEY_PASSWORD_VAL: ${{ secrets.KEY_PASSWORD }}
run: |
printf 'storeFile=%s\nstorePassword=%s\nkeyAlias=%s\nkeyPassword=%s\n' \
"$STORE_FILE" "$STORE_PASSWORD" "$KEY_ALIAS_VAL" "$KEY_PASSWORD_VAL" \
> android/key.properties
# Restore google-services.json from a base64 secret (gitignored for security).
- name: Decode google-services.json
run: echo "${{ secrets.GOOGLE_SERVICES_JSON }}" | base64 --decode > android/app/google-services.json
- name: Flutter pub get
run: flutter pub get
- name: Build APK
run: |
flutter build apk --release \
--dart-define=SUPABASE_URL=${{ secrets.SUPABASE_URL }} \
--dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} \
--dart-define=INVITE_BASE_URL=${{ secrets.INVITE_BASE_URL }} \
--dart-define=FCM_VAPID_KEY=${{ secrets.FCM_VAPID_KEY }}
- name: Build App Bundle
run: |
flutter build appbundle --release \
--dart-define=SUPABASE_URL=${{ secrets.SUPABASE_URL }} \
--dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} \
--dart-define=INVITE_BASE_URL=${{ secrets.INVITE_BASE_URL }} \
--dart-define=FCM_VAPID_KEY=${{ secrets.FCM_VAPID_KEY }}
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: release-apk
path: build/app/outputs/flutter-apk/app-release.apk
- name: Upload AAB artifact
uses: actions/upload-artifact@v4
with:
name: release-aab
path: build/app/outputs/bundle/release/app-release.aab
# ──────────────────────────────────────────────
# 2. Create GitHub Release (tag pushes only)
# ──────────────────────────────────────────────
github-release:
name: GitHub Release
needs: build-android
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download APK
uses: actions/download-artifact@v4
with:
name: release-apk
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: app-release.apk
# ──────────────────────────────────────────────
# 3. Deploy AAB to Google Play (internal track)
# ──────────────────────────────────────────────
deploy-play-store:
name: Deploy to Google Play
needs: build-android
if: >-
(startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_play_store == 'true')
runs-on: ubuntu-latest
steps:
- name: Download AAB
uses: actions/download-artifact@v4
with:
name: release-aab
- name: Upload to Play Store (internal)
uses: r0adkll/upload-google-play@v1
with:
serviceAccountJsonPlainText: ${{ secrets.PLAY_STORE_SERVICE_ACCOUNT_JSON }}
packageName: com.shenepoy.hisab
releaseFiles: app-release.aab
track: internal
status: completed
# ──────────────────────────────────────────────
# 4. Build & deploy web to Firebase Hosting
# ──────────────────────────────────────────────
deploy-web:
name: Deploy Web
if: >-
(startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.deploy_web == 'true')
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: stable
cache: true
- name: Flutter pub get
run: flutter pub get
# PowerSync web needs sqlite3.wasm and worker JS (required for live site; missing = "Unexpected token '<'" / wrong WASM MIME).
- name: Set up PowerSync web (sqlite3.wasm + workers)
run: dart run powersync:setup_web
- name: Ensure PowerSync web assets exist
run: |
test -f web/sqlite3.wasm || (echo "Missing web/sqlite3.wasm after setup_web" && exit 1)
test -f web/powersync_db.worker.js || (echo "Missing web/powersync_db.worker.js after setup_web" && exit 1)
- name: Build web
run: |
flutter build web \
--dart-define=SUPABASE_URL=${{ secrets.SUPABASE_URL }} \
--dart-define=SUPABASE_ANON_KEY=${{ secrets.SUPABASE_ANON_KEY }} \
--dart-define=INVITE_BASE_URL=${{ secrets.INVITE_BASE_URL }} \
--dart-define=SITE_URL=${{ secrets.SITE_URL }} \
--dart-define=FCM_VAPID_KEY=${{ secrets.FCM_VAPID_KEY }} \
--dart-define=FIREBASE_API_KEY=${{ secrets.FIREBASE_API_KEY }} \
--dart-define=FIREBASE_AUTH_DOMAIN=${{ secrets.FIREBASE_AUTH_DOMAIN }} \
--dart-define=FIREBASE_PROJECT_ID=${{ secrets.FIREBASE_PROJECT_ID }} \
--dart-define=FIREBASE_STORAGE_BUCKET=${{ secrets.FIREBASE_STORAGE_BUCKET }} \
--dart-define=FIREBASE_MESSAGING_SENDER_ID=${{ secrets.FIREBASE_MESSAGING_SENDER_ID }} \
--dart-define=FIREBASE_APP_ID=${{ secrets.FIREBASE_APP_ID }}
- name: Inject Firebase config into web assets
run: |
for f in build/web/index.html build/web/firebase-messaging-sw.js; do
sed -i "s|__FIREBASE_API_KEY__|${{ secrets.FIREBASE_API_KEY }}|g" "$f"
sed -i "s|__FIREBASE_AUTH_DOMAIN__|${{ secrets.FIREBASE_AUTH_DOMAIN }}|g" "$f"
sed -i "s|__FIREBASE_PROJECT_ID__|${{ secrets.FIREBASE_PROJECT_ID }}|g" "$f"
sed -i "s|__FIREBASE_STORAGE_BUCKET__|${{ secrets.FIREBASE_STORAGE_BUCKET }}|g" "$f"
sed -i "s|__FIREBASE_MESSAGING_SENDER_ID__|${{ secrets.FIREBASE_MESSAGING_SENDER_ID }}|g" "$f"
sed -i "s|__FIREBASE_APP_ID__|${{ secrets.FIREBASE_APP_ID }}|g" "$f"
done
- name: Copy static pages and PowerSync web assets for Firebase Hosting
run: |
cp -r web/privacy build/web/
cp -r web/delete-account build/web/
cp web/redirect.html build/web/
cp web/og-invite.png build/web/
sed "s|__SUPABASE_URL__|${{ secrets.SUPABASE_URL }}|g" web/invite-redirect-template.html > build/web/invite-redirect.html
cp web/sqlite3.wasm build/web/ 2>/dev/null || true
for f in web/*.worker.js; do [ -f "$f" ] && cp "$f" build/web/; done
- name: Deploy to Firebase Hosting
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
channelId: live
projectId: ${{ secrets.FIREBASE_PROJECT_ID }}