-
Notifications
You must be signed in to change notification settings - Fork 0
386 lines (343 loc) · 17.1 KB
/
deploy_dev.yml
File metadata and controls
386 lines (343 loc) · 17.1 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
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# Development Deployment Pipeline
# Automatically deploys to Firebase App Distribution for internal testing
name: Deploy to Development
# ============================================================================
# WHEN DOES THIS RUN?
# ============================================================================
on:
push:
branches: [ develop ]
workflow_dispatch: # Manual trigger
# ============================================================================
# SETTINGS
# ============================================================================
env:
FLUTTER_VERSION: '3.35.7'
JAVA_VERSION: '17'
# ============================================================================
# WHAT TO DO
# ============================================================================
jobs:
# ============================================================================
# BUILD & DEPLOY ANDROID DEV
# ============================================================================
deploy-android-dev:
name: Deploy Android Dev Build
runs-on: ubuntu-latest
timeout-minutes: 30
environment: development
steps:
# ========================================================================
# STEP 1: GET YOUR CODE
# ========================================================================
- name: 📦 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
# ========================================================================
# STEP 2: INSTALL FLUTTER
# ========================================================================
- name: 🎯 Install Flutter ${{ env.FLUTTER_VERSION }}
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: 'stable'
cache: true # This makes builds faster!
# ========================================================================
# STEP 3: INSTALL JAVA (Android needs it)
# ========================================================================
- name: ☕ Install Java ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
distribution: 'zulu'
java-version: ${{env.JAVA_VERSION}}
cache: 'gradle'
# ========================================================================
# STEP 4: SHOW FLUTTER INFO (helps with debugging)
# ========================================================================
- name: 📊 Show Flutter & Java versions
run: |
echo "Flutter version:"
flutter --version
echo "Java version:"
java -version
# ========================================================================
# STEP 5: GET PROJECT DEPENDENCIES
# ========================================================================
- name: 📦 Get Flutter Dependencies
run: flutter pub get
# ========================================================================
# STEP 6: RUN CODE GENERATION (if you use freezed, json_serializable)
# ========================================================================
- name: 🔨 Run code generation
run: flutter pub run build_runner build --delete-conflicting-outputs
continue-on-error: true # Don't fail if you don't use code generation
# ========================================================================
# STEP 7: CREATE ENVIRONMENT FILE
# ========================================================================
- name: 📝 Create .env file
run: |
mkdir -p assets/config
cat > assets/config/.env.dev << 'EOF'
APP_NAME=Password Manager Dev
APP_ENV=development
API_BASE_URL=${{ secrets.DEV_API_BASE_URL }}
API_VERSION=v1
LOGGING_ENABLED=true
DEBUG_MODE=true
ENABLE_ANALYTICS=false
ENABLE_CRASHLYTICS=false
EOF
echo "✅ Environment file created"
cat assets/config/.env.dev
# ========================================================================
# STEP 8: RUN TESTS (optional for learning)
# ========================================================================
- name: 🧪 Run tests
run: flutter test
continue-on-error: true # Don't fail build if tests fail (learning)
# ========================================================================
# STEP 9: BUILD APK
# ========================================================================
- name: 🔨 Build APK (Dev Flavor)
run: |
flutter build apk \
-t lib/main_dev.dart \
--release \
--build-number=${{ github.run_number }} \
--dart-define=FLAVOR=dev
echo "✅ APK built successfully!"
echo "📦 APK location: build/app/outputs/flutter-apk/app-release.apk"
# File size
ls -lh build/app/outputs/flutter-apk/app-release.apk
# ========================================================================
# STEP 10: CREATE ENHANCED RELEASE NOTES
# ========================================================================
- name: 📝 Generate enhanced release notes
id: release_notes
run: |
COMMIT_MSG=$(git log -1 --pretty=%B)
COMMIT_AUTHOR=$(git log -1 --pretty=%an)
BUILD_NUM=${{ github.run_number }}
BRANCH=${GITHUB_REF#refs/heads/}
BUILD_DATE=$(date '+%B %d, %Y at %I:%M %p')
COMMIT_HASH=${GITHUB_SHA:0:7}
# Get commit stats
FILES_CHANGED=$(git diff-tree --no-commit-id --name-only -r HEAD | wc -l)
# Fun build names based on build number
BUILD_NAMES=("Caffeinated Coder" "Bug Squasher" "Feature Factory" "Code Ninja" "Pixel Pusher" "Merge Master" "Deploy Dragon" "Swift Shipper" "Agile Ace" "CI/CD Champion")
BUILD_NAME=${BUILD_NAMES[$((BUILD_NUM % 10))]}
cat > release_notes.txt << EOF
╔══════════════════════════════════════════════════════════════╗
║ 🚀 PASSWORD MANAGER - DEV BUILD ║
╚══════════════════════════════════════════════════════════════╝
📱 Build Information
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• Build Number: #${BUILD_NUM} "${BUILD_NAME}"
• Branch: ${BRANCH}
• Commit: ${COMMIT_HASH}
• Built on: ${BUILD_DATE}
• Flutter: ${FLUTTER_VERSION}
👨💻 Changes by ${COMMIT_AUTHOR}
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
${COMMIT_MSG}
📊 Statistics
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• Files Modified: ${FILES_CHANGED}
• Environment: Development
• Distribution: Firebase App Distribution
⚠️ Important Notes
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
• This is a DEVELOPMENT build for internal testing only
• Debug logging is ENABLED - do not use with production data
• Analytics and crash reporting are DISABLED
• Report bugs to the development team
🎯 Testing Checklist
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
☐ App launches successfully
☐ New features work as expected
☐ No regression in existing features
☐ UI/UX is responsive and intuitive
☐ Performance is acceptable
💡 Need Help?
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Contact the dev team or create an issue on GitHub
╔══════════════════════════════════════════════════════════════╗
║ Happy Testing! 🎉 ║
╚══════════════════════════════════════════════════════════════╝
EOF
echo "release_notes_created=true" >> $GITHUB_OUTPUT
# ========================================================================
# STEP 11: UPLOAD TO FIREBASE APP DISTRIBUTION
# ========================================================================
- name: 🚀 Upload to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: ${{ secrets.FIREBASE_APP_ID_ANDROID_DEV }}
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
groups: developers, qa-team
file: build/app/outputs/flutter-apk/app-release.apk
releaseNotesFile: release_notes.txt
# ========================================================================
# STEP 12: SAVE APK IN GITHUB
# ========================================================================
- name: 📤 Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: android-dev-apk-${{ github.run_number }}
path: build/app/outputs/flutter-apk/app-release.apk
retention-days: 14
# ========================================================================
# STEP 13: SUCCESS MESSAGE
# ========================================================================
- name: ✅ Deployment complete
if: success()
run: |
echo "════════════════════════════════════════"
echo "🎉 DEPLOYMENT SUCCESSFUL!"
echo "════════════════════════════════════════"
echo "✅ Build #${{ github.run_number }} deployed"
echo "📱 Check Firebase App Distribution"
echo "💾 Download from GitHub Artifacts"
echo "════════════════════════════════════════"
# ========================================================================
# STEP 14: FAILURE MESSAGE (if something goes wrong)
# ========================================================================
- name: ❌ Deployment failed
if: failure()
run: |
echo "════════════════════════════════════════"
echo "❌ DEPLOYMENT FAILED"
echo "════════════════════════════════════════"
echo "Please check the logs above to see what went wrong"
echo "Common issues:"
echo " 1. Firebase secrets not set correctly"
echo " 2. Build errors (test locally first)"
echo " 3. Tests failing"
echo "════════════════════════════════════════"
# ============================================================================
# NOTIFY TEAM WITH ENHANCED EMAIL
# ============================================================================
notify-team:
name: Notify Team
runs-on: ubuntu-latest
needs: [deploy-android-dev]
if: always()
steps:
- name: 📦 Checkout for email context
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 📧 Send professional email notification
uses: dawidd6/action-send-mail@v6
with:
server_address: smtp.gmail.com
server_port: 465
username: ${{ secrets.EMAIL_USERNAME }}
password: ${{ secrets.EMAIL_PASSWORD }}
subject: |
Password Manager Dev Build #${{ github.run_number }} - ${{ needs.deploy-android-dev.result == 'success' && 'Deployed' || 'Failed' }}
html_body: |
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
line-height: 1.6;
color: #1a1a1a;
margin: 0;
padding: 0;
background-color: #ffffff;
}
.container {
max-width: 560px;
margin: 0 auto;
padding: 32px 24px;
}
.status {
display: inline-block;
padding: 4px 12px;
border-radius: 4px;
font-size: 13px;
font-weight: 500;
background-color: ${{ needs.deploy-android-dev.result == 'success' && '#e8f5e9' || '#ffebee' }};
color: ${{ needs.deploy-android-dev.result == 'success' && '#2e7d32' || '#c62828' }};
}
h2 {
margin: 0 0 24px 0;
font-size: 20px;
font-weight: 600;
color: #1a1a1a;
}
.info-grid {
margin: 24px 0;
border-top: 1px solid #e0e0e0;
border-bottom: 1px solid #e0e0e0;
padding: 16px 0;
}
.info-row {
display: flex;
justify-content: space-between;
padding: 8px 0;
font-size: 14px;
}
.label {
color: #757575;
}
.value {
color: #1a1a1a;
font-family: 'SF Mono', Monaco, monospace;
font-size: 13px;
}
.action {
display: inline-block;
padding: 10px 20px;
background-color: #1976d2;
color: #ffffff;
text-decoration: none;
border-radius: 4px;
font-size: 14px;
font-weight: 500;
margin-top: 16px;
}
.footer {
margin-top: 32px;
padding-top: 16px;
border-top: 1px solid #e0e0e0;
font-size: 12px;
color: #9e9e9e;
}
</style>
</head>
<body>
<div class="container">
<div>
<span class="status">${{ needs.deploy-android-dev.result == 'success' && 'Deployed' || 'Failed' }}</span>
</div>
<br>
<h2>Development Build #${{ github.run_number }}</h2>
<div class="info-grid">
<div class="info-row">
<span class="label">Branch </span>
<span class="value">${{ github.ref_name }}</span>
</div>
<div class="info-row">
<span class="label">Commit </span>
<span class="value">${{ github.sha }}</span>
</div>
<div class="info-row">
<span class="label">Environment</span>
<span class="value">Development</span>
</div>
</div>
${{ needs.deploy-android-dev.result == 'success' && '<a href="https://appdistribution.firebase.google.com" class="action">Download Build</a>' || '<a href="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" class="action">View Logs</a>' }}
<div class="footer">
Automated deployment notification
</div>
</div>
</body>
</html>
to: ${{ secrets.DEV_TEAM_EMAIL }}
from: Password Manager CI/CD <noreply@passwordmanager.com>
if: always()