Use CircleCI version 2.1 at the top of your .circleci/config.yml file.
1
version: 2.1
Add the orbs
stanza below your version, invoking the orb:
1
2
orbs:
flutter: circleci/flutter@2.0.4
Use flutter
elements in your existing workflows and jobs.
Install Flutter SDK and packages for Android machine executor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
version: '2.1'
orbs:
android: circleci/android@1.0.3
flutter: circleci/flutter@2.0.0
jobs:
distribute:
executor:
name: android/android-machine
steps:
- flutter/install_sdk_and_pub:
version: 3.0.3
- flutter/install_android_gradle_dependencies
- flutter/install_android_gem
- run:
command: bundle exec fastlane distribute
working_directory: ios
workflows:
distribute:
jobs:
- distribute
Install Flutter SDK and packages for macOS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
version: '2.1'
orbs:
flutter: circleci/flutter@2.0.0
jobs:
distribute:
macos:
xcode: 12.5.1
steps:
- flutter/install_sdk_and_pub:
version: 3.0.3
- flutter/install_ios_pod
- flutter/install_ios_gem
- run:
command: bundle exec fastlane distribute
working_directory: ios
workflows:
distribute:
jobs:
- distribute
Run static analysis(flutter analyze)
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
flutter: circleci/flutter@2.0
workflows:
test:
jobs:
- flutter/lint:
version: 3.0.3
Run Unit Test
1
2
3
4
5
6
7
8
version: '2.1'
orbs:
flutter: circleci/flutter@2.0
workflows:
test:
jobs:
- flutter/unit_test:
version: 3.0.3
Run static analysis(flutter analyze)
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
analyze-dir | Path to the directory containing your Dart source code to analyze. | No | lib | string |
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
registry | The registry to get the flutter image from, ghrc.io should be used for all flutter versions > 3.7.7. | No | cirrusci | enum |
version | The target version for the Flutter SDK. | No | 3.0.3 | string |
Run Unit Test
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
registry | The registry to get the flutter image from, ghrc.io should be used for all flutter versions > 3.7.7. | No | cirrusci | enum |
version | The target version for the Flutter SDK. | No | 3.0.3 | string |
Install your Android Rubygems(mainly fastlane) with automated caching and best practices applied. Requires lock file. https://flutter.dev/docs/deployment/cd
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
Install your Android gradle packages with automated caching and best practices applied. Requires build.gradle file.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
Install your iOS Rubygems(mainly fastlane) with automated caching and best practices applied. Requires lock file. https://flutter.dev/docs/deployment/cd
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
Install your iOS cocoapods packages with automated caching and best practices applied. Requires lock file.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
Install your flutter packages with automated caching and best practices applied. Requires lock file.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
Install Flutter SDK
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
install-location | Install path for the Flutter binaries. | No | ~/usr/development | string |
version | The target version for the Flutter SDK. | No | 3.0.3 | string |
Install Flutter SDK and your flutter packages with automated caching and best practices applied. Requires lock file.
PARAMETER | DESCRIPTION | REQUIRED | DEFAULT | TYPE |
---|---|---|---|---|
app-dir | Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root. | No | . | string |
cache-version | Change the default cache version if you need to clear the cache for any reason. | No | v1 | string |
install-location | Install path for the Flutter binaries. | No | ~/development | string |
version | The target version for the Flutter SDK. | No | 3.0.3 | string |
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
# This code is licensed from CircleCI to the user under the MIT license.
# See here for details: https://circleci.com/developer/orbs/licensing
version: 2.1
description: |
Easily install Flutter SDK, package dependencies, run unit test, lint and more on CircleCI. Supports Linux and macOS
display:
home_url: https://flutter.dev
source_url: https://github.com/CircleCI-Public/flutter-orb
commands:
install_android_gem:
description: |
Install your Android Rubygems(mainly fastlane) with automated caching and best practices applied. Requires lock file. https://flutter.dev/docs/deployment/cd
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
steps:
- restore_cache:
keys:
- bundle-<<parameters.cache-version>>-android-{{ checksum "<< parameters.app-dir >>/android/Gemfile.lock" }}
- run:
command: |
bundle config set path ./vendor/bundle
bundle install
name: Install Dependencies
working_directory: <<parameters.app-dir>>/android
- save_cache:
key: bundle-<<parameters.cache-version>>-android-{{ checksum "<< parameters.app-dir >>/android/Gemfile.lock" }}
paths:
- <<parameters.app-dir>>/android/vendor/bundle
install_android_gradle_dependencies:
description: |
Install your Android gradle packages with automated caching and best practices applied. Requires build.gradle file.
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
steps:
- restore_cache:
key: gradle-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/android/app/build.gradle" }}
- run:
command: gradle androidDependencies
name: Installing Android gradle packages
working_directory: << parameters.app-dir >>/android
- save_cache:
key: gradle-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/android/app/build.gradle" }}
paths:
- ~/.gradle/caches
- ~/.gradle/wrapper
install_ios_gem:
description: |
Install your iOS Rubygems(mainly fastlane) with automated caching and best practices applied. Requires lock file. https://flutter.dev/docs/deployment/cd
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
steps:
- restore_cache:
keys:
- bundle-<<parameters.cache-version>>-ios-{{ checksum "<< parameters.app-dir >>/ios/Gemfile.lock" }}
- run:
command: |
bundle config set path ./vendor/bundle
bundle install
name: Install Dependencies
working_directory: <<parameters.app-dir>>/ios
- save_cache:
key: bundle-<<parameters.cache-version>>-ios-{{ checksum "<< parameters.app-dir >>/ios/Gemfile.lock" }}
paths:
- <<parameters.app-dir>>/ios/vendor/bundle
install_ios_pod:
description: |
Install your iOS cocoapods packages with automated caching and best practices applied. Requires lock file.
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
steps:
- restore_cache:
keys:
- pod-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/ios/Podfile.lock" }}
- run:
command: pod install
name: Install Dependencies
working_directory: <<parameters.app-dir>>/ios
- save_cache:
key: pod-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/ios/Podfile.lock" }}
paths:
- <<parameters.app-dir>>/ios/Pods
install_pub:
description: |
Install your flutter packages with automated caching and best practices applied. Requires lock file.
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
steps:
- restore_cache:
keys:
- pub-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/pubspec.lock" }}-{{ arch }}
- run:
command: flutter pub get
name: Install Dependencies
working_directory: <<parameters.app-dir>>
- save_cache:
key: pub-<<parameters.cache-version>>-{{ checksum "<< parameters.app-dir >>/pubspec.lock" }}-{{ arch }}
paths:
- <<parameters.app-dir>>/.dart_tool
install_sdk:
description: |
Install Flutter SDK
parameters:
install-location:
default: ~/usr/development
description: Install path for the Flutter binaries.
type: string
version:
default: 3.0.3
description: The target version for the Flutter SDK.
type: string
steps:
- restore_cache:
keys:
- flutter-<<parameters.version>>-{{ arch }}
- run:
command: "#!/usr/bin/env bash\n\nINSTALL_LOCATION=$(eval \"echo $ORB_EVAL_INSTALL_LOCATION\")\n\nfunction install_flutter() {\n local machine=${1:-\"Linux\"}\n local arch=${2:-\"amd64\"}\n\n [[ $machine == \"Darwin\" ]] && uname=macos || uname=linux\n [[ $arch =~ \"arm64\" ]] && version=\"flutter_${uname}_arm64\" || version=\"flutter_${uname}\"\n [[ $uname == \"linux\" ]] && suffix=\"tar.xz\" || suffix=\"zip\"\n\n baseurl=\"https://storage.googleapis.com/flutter_infra_release/releases/stable\"\n fullurl=\"$baseurl/$uname/${version}_$ORB_VAL_FLUTTER_SDK_VERSION-stable.${suffix}\"\n\n curl -o \"flutter_sdk.${suffix}\" \"$fullurl\"\n\n mkdir -p $INSTALL_LOCATION\n \n if [ $suffix == \"tar.xz\" ]; then\n tar xf flutter_sdk.tar.xz -C \"$INSTALL_LOCATION\"\n else\n unzip -oqq flutter_sdk.zip -d \"$INSTALL_LOCATION\"\n fi\n\n rm -f \"flutter_sdk.${suffix}\"\n}\n\n\nif ! command -v flutter &> /dev/null; then\n install_flutter \"$(uname)\" \"$(uname -m)\"\nelse\n echo \"Previous Flutter installation detected: $(eval command -v flutter)\"\n exit 0\nfi\n\necho \"export PATH=$INSTALL_LOCATION/flutter/bin:\\$PATH\" >> \"$BASH_ENV\"\n\n# shellcheck source=/dev/null\nsource \"$BASH_ENV\"\nwhich flutter\n"
environment:
ORB_EVAL_INSTALL_LOCATION: <<parameters.install-location>>
ORB_VAL_FLUTTER_SDK_VERSION: <<parameters.version>>
name: Install Flutter SDK if it does not exists
- run:
command: flutter doctor
name: Run flutter doctor
- save_cache:
key: flutter-<<parameters.version>>-{{ arch }}
paths:
- <<parameters.install-location>>
install_sdk_and_pub:
description: |
Install Flutter SDK and your flutter packages with automated caching and best practices applied. Requires lock file.
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
install-location:
default: ~/development
description: Install path for the Flutter binaries.
type: string
version:
default: 3.0.3
description: The target version for the Flutter SDK.
type: string
steps:
- install_sdk:
install-location: <<parameters.install-location>>
version: <<parameters.version>>
- install_pub:
app-dir: <<parameters.app-dir>>
cache-version: <<parameters.app-dir>>
jobs:
lint:
description: |
Run static analysis(flutter analyze)
docker:
- image: <<parameters.registry>>/flutter:<<parameters.version>>
parameters:
analyze-dir:
default: lib
description: Path to the directory containing your Dart source code to analyze.
type: string
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
registry:
default: cirrusci
description: The registry to get the flutter image from, ghrc.io should be used for all flutter versions > 3.7.7.
enum:
- cirrusci
- ghcr.io/cirruslabs
type: enum
version:
default: 3.0.3
description: The target version for the Flutter SDK.
type: string
steps:
- checkout
- install_pub:
app-dir: <<parameters.app-dir>>
cache-version: <<parameters.cache-version>>
- run:
command: flutter analyze <<parameters.analyze-dir>>
name: Run static analysis
working_directory: <<parameters.app-dir>>
unit_test:
description: |
Run Unit Test
docker:
- image: <<parameters.registry>>/flutter:<<parameters.version>>
parameters:
app-dir:
default: .
description: Path to the directory containing your pubspec.yaml file. Not needed if pubspec.yaml lives in the root.
type: string
cache-version:
default: v1
description: Change the default cache version if you need to clear the cache for any reason.
type: string
registry:
default: cirrusci
description: The registry to get the flutter image from, ghrc.io should be used for all flutter versions > 3.7.7.
enum:
- cirrusci
- ghcr.io/cirruslabs
type: enum
version:
default: 3.0.3
description: The target version for the Flutter SDK.
type: string
steps:
- checkout
- install_pub:
app-dir: <<parameters.app-dir>>
cache-version: <<parameters.cache-version>>
- run:
command: flutter test
name: Run Unit Test
working_directory: <<parameters.app-dir>>
examples:
install_for_android_machine:
description: |
Install Flutter SDK and packages for Android machine executor
usage:
version: "2.1"
orbs:
android: circleci/android@1.0.3
flutter: circleci/flutter@2.0.0
jobs:
distribute:
executor:
name: android/android-machine
steps:
- flutter/install_sdk_and_pub:
version: 3.0.3
- flutter/install_android_gradle_dependencies
- flutter/install_android_gem
- run:
command: bundle exec fastlane distribute
working_directory: ios
workflows:
distribute:
jobs:
- distribute
install_for_macos:
description: |
Install Flutter SDK and packages for macOS
usage:
version: "2.1"
orbs:
flutter: circleci/flutter@2.0.0
jobs:
distribute:
macos:
xcode: 12.5.1
steps:
- flutter/install_sdk_and_pub:
version: 3.0.3
- flutter/install_ios_pod
- flutter/install_ios_gem
- run:
command: bundle exec fastlane distribute
working_directory: ios
workflows:
distribute:
jobs:
- distribute
lint:
description: |
Run static analysis(flutter analyze)
usage:
version: "2.1"
orbs:
flutter: circleci/flutter@2.0
workflows:
test:
jobs:
- flutter/lint:
version: 3.0.3
unit_test:
description: |
Run Unit Test
usage:
version: "2.1"
orbs:
flutter: circleci/flutter@2.0
workflows:
test:
jobs:
- flutter/unit_test:
version: 3.0.3