-
Notifications
You must be signed in to change notification settings - Fork 415
198 lines (166 loc) · 5.01 KB
/
build_deploy.yml
File metadata and controls
198 lines (166 loc) · 5.01 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
name: Publish package to pub.dev
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
jobs:
test:
name: Test (root + example)
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: read
env:
CI: true
steps:
- uses: actions/checkout@v6
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- run: flutter --version
- name: Flutter pub get (root)
run: flutter pub get
- name: Flutter test (root)
run: flutter test
- name: Flutter pub get (example)
working-directory: example
run: flutter pub get
- name: Flutter test (example)
working-directory: example
run: flutter test
verify:
name: Verify (${{ matrix.target }})
runs-on: ${{ matrix.os }}
timeout-minutes: ${{ matrix.timeout }}
needs: [test]
permissions:
contents: read
strategy:
fail-fast: false
matrix:
include:
- target: android
os: ubuntu-latest
timeout: 45
- target: ios
os: macos-latest
timeout: 60
env:
CI: true
GRADLE_OPTS: -Dorg.gradle.daemon=false -Dorg.gradle.vfs.watch=false -Dorg.gradle.caching=true
steps:
- uses: actions/checkout@v6
- name: Set up Java 17
if: matrix.target == 'android'
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: "17"
cache: gradle
cache-dependency-path: |
example/android/**/*.gradle*
example/android/**/gradle-wrapper.properties
example/android/gradle.properties
- name: Set up Android SDK
if: matrix.target == 'android'
uses: android-actions/setup-android@v3
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: stable
cache: true
- run: flutter --version
- name: Cache CocoaPods
if: matrix.target == 'ios'
uses: actions/cache@v5
with:
path: |
~/.cocoapods
~/Library/Caches/CocoaPods
example/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
- name: Cache CocoaPods gem
if: matrix.target == 'ios'
uses: actions/cache@v5
with:
path: ~/.gem
key: ${{ runner.os }}-cocoapods-gem-v1
- name: Add user gem bin to PATH
if: matrix.target == 'ios'
run: echo "$(ruby -r rubygems -e 'print Gem.user_dir')/bin" >> "$GITHUB_PATH"
- name: Install CocoaPods
if: matrix.target == 'ios'
run: gem list -i cocoapods || gem install cocoapods -N --user-install
- name: Flutter pub get (root)
run: flutter pub get
- name: Flutter pub get (example)
working-directory: example
run: flutter pub get
- name: Build example APK (debug, verbose)
if: matrix.target == 'android'
working-directory: example
run: flutter build apk --debug -v
- name: Build example iOS (no-codesign, verbose)
if: matrix.target == 'ios'
working-directory: example
run: flutter build ios --no-codesign -v
publish:
name: Publish Plugin
runs-on: ubuntu-latest
needs: [verify]
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: dart-lang/setup-dart@v1
- name: Set up Flutter
uses: subosito/flutter-action@v2
with:
channel: "stable"
cache: true
- run: flutter --version
- run: flutter pub get
- name: Publish package
run: flutter pub publish --force
release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: [publish]
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Build release notes from CHANGELOG
env:
TAG_NAME: ${{ github.ref_name }}
run: |
version="${TAG_NAME#v}"
awk -v version="$version" '
$0 == "## " version { found=1; print; next }
found && /^## / { exit }
found { print }
' CHANGELOG.md > release_notes.md
if [ ! -s release_notes.md ]; then
echo "Could not find CHANGELOG entry for version ${version}"
exit 1
fi
- name: Create or update GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
run: |
if gh release view "$TAG_NAME" >/dev/null 2>&1; then
gh release edit "$TAG_NAME" \
--title "$TAG_NAME" \
--notes-file release_notes.md
else
gh release create "$TAG_NAME" \
--title "$TAG_NAME" \
--notes-file release_notes.md \
--latest
fi