Skip to content

Commit e066c65

Browse files
committed
ci(workflow): 添加缓存步骤以优化构建性能
添加对Flutter SDK、Pub依赖、Gradle依赖和Linux系统依赖的缓存配置,以减少构建时间并提高CI效率。这些更改通过重用之前下载的依赖项来避免重复下载。
1 parent 106107d commit e066c65

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

.github/workflows/release.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,32 @@ jobs:
2525
distribution: "zulu"
2626
java-version: "17"
2727

28+
- name: Cache Flutter SDK
29+
uses: actions/cache@v3
30+
with:
31+
path: |
32+
~/.pub-cache
33+
${{ runner.tool_cache }}/flutter
34+
key: ${{ runner.os }}-flutter-${{ hashFiles('**/pubspec.lock') }}
35+
restore-keys: |
36+
${{ runner.os }}-flutter-
37+
2838
- name: Setup Flutter
2939
uses: subosito/flutter-action@v2
3040
with:
3141
flutter-version: "3.24.0"
3242
channel: "stable"
43+
cache: true
44+
45+
- name: Cache Pub dependencies
46+
uses: actions/cache@v3
47+
with:
48+
path: |
49+
~/.pub-cache
50+
.dart_tool
51+
key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.lock') }}
52+
restore-keys: |
53+
${{ runner.os }}-pub-
3354
3455
- name: Get dependencies
3556
run: flutter pub get
@@ -54,6 +75,17 @@ jobs:
5475
git commit -m "chore: update version to ${{ steps.version.outputs.version }}" || exit 0
5576
git push origin HEAD:main || exit 0
5677
78+
- name: Cache Gradle dependencies
79+
uses: actions/cache@v3
80+
with:
81+
path: |
82+
~/.gradle/caches
83+
~/.gradle/wrapper
84+
~/.android/build-cache
85+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
86+
restore-keys: |
87+
${{ runner.os }}-gradle-
88+
5789
- name: Setup signingQueue
5890
run: |
5991
echo "${{ secrets.KEYSTORE_BASE64 }}" | base64 --decode > android/app/release-key.jks
@@ -84,6 +116,16 @@ jobs:
84116
continue-on-error: true
85117
run: flutter build web --release
86118

119+
- name: Cache Linux dependencies
120+
uses: actions/cache@v3
121+
with:
122+
path: |
123+
/var/cache/apt
124+
/var/lib/apt
125+
key: ${{ runner.os }}-apt-${{ hashFiles('.github/workflows/release.yml') }}
126+
restore-keys: |
127+
${{ runner.os }}-apt-
128+
87129
- name: Build Linux
88130
continue-on-error: true
89131
run: |

0 commit comments

Comments
 (0)