-
Notifications
You must be signed in to change notification settings - Fork 33
256 lines (221 loc) · 8.45 KB
/
Copy pathcache-warm.yml
File metadata and controls
256 lines (221 loc) · 8.45 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
name: Warm Caches
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: read
jobs:
warm-caches-linux:
name: Warm caches (Linux)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: '17'
- name: Get Java Version
run: echo "JAVA_VERSION=$(java -XshowSettings:properties -version 2>&1 | grep 'java.runtime.version' | awk '{print $3}')" >> $GITHUB_ENV
- name: Setup Flutter (cached)
id: cache_flutter_linux
uses: subosito/flutter-action@v2
with:
flutter-version-file: .flutter-version
channel: 'main'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
cache-path: '${{ runner.tool_cache }}/flutter'
- name: Flutter precache (Linux)
run: |
flutter config --enable-linux-desktop
flutter precache --linux
- name: Cache Pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- name: Get dependencies
run: |
# 如果 pubspec.lock 未变化,actions/cache 会命中,跳过更新
# 但需要执行一次 pub get 以确保缓存目录结构存在
flutter pub get
- name: Cache Gradle
id: cache_gradle_linux
uses: actions/cache@v5
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('pubspec.lock', '**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Warm Android build (Debug)
if: ${{ steps.cache_gradle_linux.outputs.cache-hit != 'true' || steps.cache_flutter_linux.outputs.cache-hit != 'true' }}
run: |
# 通过一次 Debug 构建触发 Gradle 依赖解析与下载,以填充缓存。
# Debug 构建无需签名配置,避免 release 构建的密钥要求。
flutter build apk --debug --target-platform=android-arm64
- name: Cache CMake
id: cache_cmake_linux
uses: actions/cache@v5
with:
path: |
build/linux
~/.cmake
key: ${{ runner.os }}-java-${{ env.JAVA_VERSION }}-cmake-debug-${{ hashFiles('pubspec.lock', '**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-java-${{ env.JAVA_VERSION }}-cmake-debug-
- name: Install Linux dependencies
if: ${{ steps.cache_cmake_linux.outputs.cache-hit != 'true' || steps.cache_flutter_linux.outputs.cache-hit != 'true' }}
run: |
sudo apt-get update -y
sudo apt-get install -y ninja-build libgtk-3-dev libblkid-dev libsecret-1-dev file libfuse2 lld
- name: Build Linux (Debug)
if: ${{ steps.cache_cmake_linux.outputs.cache-hit != 'true' || steps.cache_flutter_linux.outputs.cache-hit != 'true' }}
run: |
if [ "${{ steps.cache_cmake_linux.outputs.cache-hit }}" != "true" ]; then
echo "Cache miss or partial hit, cleaning build directory to avoid stale JDK paths..."
rm -rf build/linux
fi
flutter build linux --debug
- name: Cache AppImageTool
uses: actions/cache@v5
with:
path: appimagetool-x86_64.AppImage
key: ${{ runner.os }}-appimagetool-continuous
restore-keys: |
${{ runner.os }}-appimagetool-
- name: Download AppImageTool if missing
run: |
if [ ! -f appimagetool-x86_64.AppImage ]; then
wget -O appimagetool-x86_64.AppImage https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
else
echo "AppImageTool present via cache; skip download"
fi
warm-caches-windows:
name: Warm caches (Windows)
runs-on: windows-2022
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup Java
uses: actions/setup-java@v5
with:
distribution: 'zulu'
java-version: '17'
- name: Setup Flutter (cached)
id: cache_flutter_windows
uses: subosito/flutter-action@v2
with:
flutter-version-file: .flutter-version
channel: 'main'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
cache-path: '${{ runner.tool_cache }}/flutter'
- name: Flutter precache (Windows)
run: |
flutter config --enable-windows-desktop
flutter precache --windows
- name: Cache Pub dependencies
uses: actions/cache@v5
with:
path: ~\AppData\Local\Pub\Cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- name: Get dependencies
run: |
flutter pub get
- name: Cache Visual Studio
id: cache_vs_windows
uses: actions/cache@v5
with:
path: C:\Users\runneradmin\AppData\Local\Microsoft\VisualStudio
key: ${{ runner.os }}-vs-state-v2-debug-${{ hashFiles('pubspec.lock', '**/CMakeLists.txt') }}
restore-keys: |
${{ runner.os }}-vs-state-v2-debug-
- name: Clear stale Windows CMake build
run: |
Remove-Item -Recurse -Force build/windows -ErrorAction SilentlyContinue
- name: Build Windows (Debug)
if: ${{ steps.cache_vs_windows.outputs.cache-hit != 'true' || steps.cache_flutter_windows.outputs.cache-hit != 'true' }}
env:
CMAKE_INCLUDE_PATH: ${{ env.JAVA_HOME }}\include;${{ env.JAVA_HOME }}\include\win32
run: |
flutter build windows --debug
warm-caches-macos:
name: Warm caches (macOS)
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Select Xcode 26.1.1
run: |
sudo xcode-select -s /Applications/Xcode_26.1.1.app
xcodebuild -version
- name: Setup Flutter (cached)
id: cache_flutter_macos
uses: subosito/flutter-action@v2
with:
flutter-version-file: .flutter-version
channel: 'main'
cache: true
cache-key: 'flutter-:os:-:channel:-:version:-:arch:-:hash:'
cache-path: '${{ runner.tool_cache }}/flutter'
- name: Flutter precache (macOS & iOS)
run: |
flutter config --enable-macos-desktop
flutter precache --macos --ios
- name: Cache Pub dependencies
uses: actions/cache@v5
with:
path: ~/.pub-cache
key: ${{ runner.os }}-pub-cache-${{ hashFiles('pubspec.lock') }}
restore-keys: |
${{ runner.os }}-pub-cache-
- name: Get dependencies
run: |
flutter pub get
- name: Cache CocoaPods
id: cache_pods_macos
uses: actions/cache@v5
with:
path: |
ios/Pods
macos/Pods
~/.cocoapods
key: ${{ runner.os }}-pods-${{ hashFiles('pubspec.lock', 'ios/Podfile', 'macos/Podfile') }}
restore-keys: |
${{ runner.os }}-pods-
- name: Install CocoaPods dependencies (no build)
if: ${{ steps.cache_pods_macos.outputs.cache-hit != 'true' || steps.cache_flutter_macos.outputs.cache-hit != 'true' }}
run: |
if [ -f ios/Podfile ]; then
cd ios
pod install --repo-update
cd -
fi
if [ -f macos/Podfile ]; then
cd macos
pod install --repo-update
cd -
fi
- name: Cache Xcode DerivedData
id: cache_xcode_macos
uses: actions/cache@v5
with:
path: ~/Library/Developer/Xcode/DerivedData
key: ${{ runner.os }}-xcode-debug-${{ hashFiles('pubspec.lock', '**/project.pbxproj') }}
restore-keys: |
${{ runner.os }}-xcode-debug-
- name: Build macOS (Debug)
if: ${{ steps.cache_xcode_macos.outputs.cache-hit != 'true' || steps.cache_pods_macos.outputs.cache-hit != 'true' || steps.cache_flutter_macos.outputs.cache-hit != 'true' }}
run: |
flutter build macos --debug