-
Notifications
You must be signed in to change notification settings - Fork 1
232 lines (193 loc) · 8.43 KB
/
build.yml
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
name: Build and test
on:
pull_request:
branches: [develop, production]
workflow_dispatch:
workflow_call:
inputs:
storeArtifacts:
type: boolean
required: false
outputs:
version_tag:
description: "Version used for Git tag"
value: ${{ jobs.version.outputs.version_tag }}
env:
FLUTTER_VERSION: 3.10.2
JAVA_VERSION: 11.x
jobs:
version:
name: Versioning
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Determine versioning
uses: paulhatch/[email protected]
id: versioning
with:
tag_prefix: "v"
major_pattern: "(MAJOR)"
minor_pattern: "(MINOR)"
format: "${major}.${minor}.${patch}"
bump_each_commit: false
- name: Determine build version
id: build_version
run: |
BUILD_NO=$((${{ github.run_number }} + 100))
echo "::set-output name=build_no::$BUILD_NO"
- name: Print versioning
run: |
echo "Version: $VERSION"
echo "Version Tag: $VERSION_TAG"
echo "Run No: $BUILD_NO"
env:
VERSION: ${{ steps.versioning.outputs.version }}
VERSION_TAG: ${{ steps.versioning.outputs.version_tag }}
BUILD_NO: ${{ steps.build_version.outputs.build_no }}
outputs:
version: ${{ steps.versioning.outputs.version }}
version_tag: ${{ steps.versioning.outputs.version_tag }}
build_version: ${{ steps.build_version.outputs.build_no }}
build_ios:
name: Build iOS App
runs-on: macos-latest
needs: [version]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install Apple certificate and provisioning profile (dev)
if: github.ref_name != 'production'
run: .github/scripts/setup-certs.command
env:
APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT }}
APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERTIFICATE_DEVELOPMENT_PASSWORD }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_DEVELOPMENT }}
APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }}
- name: Install Apple certificate and provisioning profile (prod)
if: github.ref_name == 'production'
run: .github/scripts/setup-certs.command
env:
APPLE_IOS_SIGNING_CERT: ${{ secrets.APPLE_IOS_SIGNING_CERT_PROD }}
APPLE_IOS_SIGNING_CERT_PW: ${{ secrets.APPLE_IOS_SIGNING_CERT_PW }}
APPLE_IOS_PROVISIONING_PROFILE: ${{ secrets.APPLE_IOS_PROVISIONING_PROFILE_PROD }}
APPLE_KEYCHAIN_PW: ${{ secrets.APPLE_KEYCHAIN_PW }}
- name: Setup Java
uses: actions/[email protected]
with:
distribution: "adopt"
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Download dependencies
run: flutter pub get
- name: Set URI (prod)
if: github.ref_name == 'production'
run: sed -i '' 's/.env.develop/.env.production/' lib/env/env.dart
- name: Generate code
run: dart run build_runner build
- name: Build iOS (dev)
if: github.ref_name != 'production'
run: flutter build ios --flavor development --release --no-codesign --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_development.dart
- name: Build iOS (prod)
if: github.ref_name == 'production'
run: flutter build ios --flavor production --release --no-codesign --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_production.dart
- name: Build resolve Swift dependencies (dev)
if: github.ref_name != 'production'
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development
- name: Build resolve Swift dependencies (prod)
run: xcodebuild -resolvePackageDependencies -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production
if: github.ref_name == 'production'
- name: Build xArchive (dev)
if: github.ref_name != 'production'
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme development -configuration Release-development DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="development" clean archive CODE_SIGN_IDENTITY="iPhone Developer"
- name: Build xArchive (prod)
if: github.ref_name == 'production'
run: |
xcodebuild -workspace ios/Runner.xcworkspace -scheme production -configuration Release-production DEVELOPMENT_TEAM=Y5U9T77F2K -sdk 'iphoneos' -destination 'generic/platform=iOS' -archivePath build-output/app.xcarchive PROVISIONING_PROFILE_SPECIFIER="githubactions-prod" clean archive CODE_SIGN_IDENTITY="Apple Distribution"
- name: Export ipa (dev)
if: github.ref_name != 'production'
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.dev.plist
- name: Export ipa (prod)
if: github.ref_name == 'production'
run: xcodebuild -exportArchive -archivePath build-output/app.xcarchive -exportPath build-output/ios -exportOptionsPlist ios/exportOptions.prod.plist
- name: Upload iOS build
if: ${{ inputs.storeArtifacts }}
uses: actions/[email protected]
with:
name: ios
path: build-output/ios
retention-days: 1
if-no-files-found: error
build_android:
name: Build Android App
runs-on: ubuntu-latest
needs: [version]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Java
uses: actions/[email protected]
with:
distribution: "adopt"
java-version: ${{ env.JAVA_VERSION }}
- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Download dependencies
run: flutter pub get
- name: Set URI (prod)
if: github.ref_name == 'production'
run: sed -i 's/.env.develop/.env.production/' lib/env/env.dart
- name: Generate code
run: dart run build_runner build
- name: Build appbundle (dev)
if: github.ref_name != 'production'
run: flutter build apk --flavor development --release --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_development.dart
- name: Build appbundle (prod)
if: github.ref_name == 'production'
run: flutter build apk --flavor production --release --dart-define=IS_PROD=true --build-name ${{ needs.version.outputs.version }} --build-number ${{ needs.version.outputs.build_version }} --target lib/main_production.dart
- name: Upload Android build
if: ${{ inputs.storeArtifacts }}
uses: actions/[email protected]
with:
name: android
path: build/app/outputs/flutter-apk
retention-days: 1
if-no-files-found: error
test:
name: Test Flutter app
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Setup Flutter environment
uses: subosito/[email protected]
with:
flutter-version: ${{ env.FLUTTER_VERSION }}
channel: "stable"
- name: Download dependencies
run: flutter pub get
- name: Generate code
run: dart run build_runner build
- name: Check formatting
run: dart format --set-exit-if-changed .
- name: Static Analysis
run: flutter analyze
- name: Run Code Metrics
run: dart run dart_code_metrics:metrics --reporter=github lib
- name: Run tests
run: flutter test --coverage
- name: Upload test report to Codecov
uses: codecov/[email protected]
with:
flags: unittests
file: coverage/lcov.info