Skip to content

Commit c0ca4f0

Browse files
committed
github: make cache key more precise
1 parent c2c90da commit c0ca4f0

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

.github/workflows/build.yml

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,12 @@ jobs:
7070
shell: bash
7171
run: |
7272
[[ "$(xcode-select -p)" == "${{ env.BUILD_XCODE_PATH }}"* ]] || sudo xcode-select -s "${{ env.BUILD_XCODE_PATH }}"
73-
- name: Cache Sysroot
73+
- name: Check Cache
7474
id: cache-sysroot
75-
uses: actions/cache@v4
75+
uses: actions/cache/restore@v4
7676
with:
77-
path: sysroot-${{ matrix.platform }}-${{ matrix.arch }}
77+
path: ./sysroot-${{ matrix.platform }}-${{ matrix.arch }}
7878
key: ${{ matrix.platform }}-${{ matrix.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
79-
upload-chunk-size: 1048576 # 1 MiB
8079
lookup-only: true
8180
- name: Setup Path
8281
shell: bash
@@ -103,34 +102,41 @@ jobs:
103102
with:
104103
name: Sysroot-${{ matrix.platform }}-${{ matrix.arch }}
105104
path: sysroot.tgz
105+
- name: Save Cache
106+
if: steps.cache-sysroot.outputs.cache-hit != 'true'
107+
uses: actions/cache/save@v4
108+
with:
109+
path: ./sysroot-${{ matrix.platform }}-${{ matrix.arch }}
110+
key: ${{ steps.cache-sysroot.outputs.cache-primary-key }}-${{ github.sha }}
111+
upload-chunk-size: 1048576 # 1 MiB
106112
build-sysroot-universal:
107113
name: Build Sysroot (Universal Mac)
108114
runs-on: ${{ fromJSON(needs.configuration.outputs.github-runner) }}
109115
needs: [configuration, build-sysroot]
110116
steps:
111117
- name: Checkout
112118
uses: actions/checkout@v3
113-
- name: Cache Sysroot (Universal Mac)
119+
- name: Check Cache (Universal Mac)
114120
id: cache-sysroot-universal
115-
uses: actions/cache@v4
121+
uses: actions/cache/restore@v4
116122
with:
117-
path: sysroot-macOS-arm64_x86_64
123+
path: ./sysroot-macOS-arm64_x86_64
118124
key: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}
119125
lookup-only: true
120126
- name: Cache Sysroot (arm64)
121127
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
122128
id: cache-sysroot-arm64
123-
uses: actions/cache@v4
129+
uses: actions/cache/restore@v4
124130
with:
125-
path: sysroot-macos-arm64
131+
path: ./sysroot-macos-arm64
126132
key: macos-arm64-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
127133
fail-on-cache-miss: true
128134
- name: Cache Sysroot (x86_64)
129135
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
130136
id: cache-sysroot-x86_64
131-
uses: actions/cache@v4
137+
uses: actions/cache/restore@v4
132138
with:
133-
path: sysroot-macos-x86_64
139+
path: ./sysroot-macos-x86_64
134140
key: macos-x86_64-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
135141
fail-on-cache-miss: true
136142
- name: Pack Universal Sysroot
@@ -146,6 +152,13 @@ jobs:
146152
with:
147153
name: Sysroot-macos-universal
148154
path: sysroot.tgz
155+
- name: Save Cache (Universal Mac)
156+
if: steps.cache-sysroot-universal.outputs.cache-hit != 'true'
157+
uses: actions/cache/save@v4
158+
with:
159+
path: ./sysroot-macOS-arm64_x86_64
160+
key: ${{ steps.cache-sysroot.outputs.cache-primary-key }}-${{ github.sha }}
161+
upload-chunk-size: 1048576 # 1 MiB
149162
build-utm:
150163
name: Build UTM
151164
runs-on: ${{ fromJSON(needs.configuration.outputs.runner) }}
@@ -169,9 +182,9 @@ jobs:
169182
submodules: recursive
170183
- name: Cache Sysroot
171184
id: cache-sysroot
172-
uses: actions/cache@v4
185+
uses: actions/cache/restore@v4
173186
with:
174-
path: sysroot-${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}
187+
path: ./sysroot-${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}
175188
key: ${{ matrix.configuration.platform }}-${{ matrix.configuration.arch }}-${{ hashFiles('scripts/build_dependencies.sh') }}-${{ hashFiles('patches/**') }}
176189
fail-on-cache-miss: true
177190
- name: Setup Xcode
@@ -198,9 +211,9 @@ jobs:
198211
submodules: recursive
199212
- name: Cache Sysroot
200213
id: cache-sysroot
201-
uses: actions/cache@v4
214+
uses: actions/cache/restore@v4
202215
with:
203-
path: sysroot-macOS-arm64_x86_64
216+
path: ./sysroot-macOS-arm64_x86_64
204217
key: macos-universal-${{ hashFiles('scripts/build_dependencies.sh', 'scripts/pack_dependencies.sh') }}-${{ hashFiles('patches/**') }}
205218
fail-on-cache-miss: true
206219
- name: Setup Xcode

0 commit comments

Comments
 (0)