forked from hrishikesh-kadam/setup-flutter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
117 lines (107 loc) · 3.88 KB
/
action.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
name: 'hrk-setup-flutter'
author: 'Hrishikesh Kadam <[email protected]>'
description: 'Composite GitHub Action to setup and cache the Flutter SDK.'
inputs:
ref:
description: 'Channel (stable, beta or master), version(3.7.8) or any git reference(3.9.0-0.1.pre).'
required: false
default: 'stable'
installationPath:
description: 'Installation Path of Flutter SDK.'
required: false
default: '${{ runner.tool_cache }}/flutter'
actionsCache:
description: 'Cache Flutter SDK for subsequent GitHub Actions Workflow.'
required: false
default: 'true'
actionsCacheKey:
description: "An explicit key for a cache entry.
SHA of ref's HEAD will be appended to the given key.
Default key will be computed as `flutter-{OS}-{ref}-{ref_head}`."
required: false
default: ''
setFlutterRootPath:
description: 'Set FLUTTER_ROOT to path where Flutter is installed.'
required: false
default: 'false'
setPubCachePath:
description: 'Set PUB_CACHE to desired path, where pub saves dependencies.'
required: false
default: ''
addPubCacheBinToPath:
description: 'Add PUB_CACHE bin to PATH.
Note: On Windows, activated global packages can be run by without specifying
`dart pub global run` only on pwsh, cmd and powershell.'
required: false
default: 'false'
flutterPrecache:
description: "Populate the Flutter tool's cache of binary artifacts.
For additional download options, see `flutter help precache`."
required: false
default: 'false'
pubSpecPath:
description: 'pubspec.yaml location.'
required: false
default: 'pubspec.yaml'
runs:
using: 'composite'
steps:
- name: Get Flutter version from pubspec.yaml
id: flutter-version
uses: jbutcher5/[email protected]
with:
file: ${{ inputs.pubSpecPath }}
key-path: '["environment","flutter"]'
- name: Run init script
run: $GITHUB_ACTION_PATH/src/init.sh
shell: bash
env:
SETUP_FLUTTER_REF: ${{ steps.flutter-version.outputs.data }}
SETUP_FLUTTER_INSTALLATION_PATH: ${{ inputs.installationPath }}
SETUP_FLUTTER_ACTIONS_CACHE: ${{ inputs.actionsCache }}
SETUP_FLUTTER_ACTIONS_CACHE_KEY: ${{ inputs.actionsCacheKey }}
- name: Check if Flutter is cached
if: inputs.actionsCache == 'true'
id: cache-flutter
uses: actions/cache@v3
with:
path: ${{ env.SETUP_FLUTTER_INSTALLATION_PATH }}
key: ${{ env.SETUP_FLUTTER_ACTIONS_CACHE_KEY }}
- name: Clone Flutter repository if not cached
if: inputs.actionsCache != 'true' || steps.cache-flutter.outputs.cache-hit != 'true'
run: |
git clone --branch ${{ inputs.ref }} \
https://github.com/flutter/flutter $SETUP_FLUTTER_INSTALLATION_PATH
shell: bash
- name: Set FLUTTER_ROOT path
if: inputs.setFlutterRootPath == 'true'
run: echo "FLUTTER_ROOT=$SETUP_FLUTTER_INSTALLATION_PATH" >> $GITHUB_ENV
shell: bash
- name: Add Flutter to PATH
run: echo "$SETUP_FLUTTER_INSTALLATION_PATH/bin" >> $GITHUB_PATH
shell: bash
- name: Set PUB_CACHE path
if: inputs.setPubCachePath != ''
run: echo "PUB_CACHE=${{ inputs.setPubCachePath }}" >> $GITHUB_ENV
shell: bash
- name: Add PUB_CACHE bin to PATH
if: inputs.addPubCacheBinToPath == 'true'
run: $GITHUB_ACTION_PATH/src/add-pub-cache-bin-to-path.sh
shell: bash
- name: Run Flutter Precache
if: inputs.flutterPrecache != 'false' &&
(inputs.actionsCache != 'true' || steps.cache-flutter.outputs.cache-hit != 'true')
run: |
if [[ "${{ inputs.flutterPrecache }}" == "true" ]]; then
set -x
flutter precache
else
set -x
flutter precache ${{ inputs.flutterPrecache }}
fi
shell: bash
- run: flutter --version
shell: bash
branding:
icon: 'heart'
color: 'blue'