Skip to content

Commit c5d2102

Browse files
authored
Cache vcpkg binary cache for macOS (#8560)
1 parent d735e65 commit c5d2102

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

.github/workflows/main.yml

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -362,8 +362,6 @@ jobs:
362362
build-macos:
363363
name: build-macos-${{ matrix.arch }}
364364
runs-on: ${{ (matrix.arch == 'arm64' && 'macos-14') || 'macos-13' }}
365-
env:
366-
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
367365

368366
strategy:
369367
fail-fast: false
@@ -384,14 +382,16 @@ jobs:
384382

385383
- name: Prepare - Install tools
386384
run: |
387-
brew install automake autoconf-archive libtool ninja
385+
brew install --quiet automake autoconf-archive libtool ninja
388386
389-
- name: Export GitHub Actions cache environment variables
390-
uses: actions/github-script@v7
387+
- name: Restore vcpkg cache
388+
uses: actions/cache/restore@v4
389+
id: restore-vcpkg-cache
391390
with:
392-
script: |
393-
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
394-
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
391+
path: ~/.cache/vcpkg/archives
392+
key: vcpkg-cache-${{ runner.os }}-${{ matrix.arch }}-${{ hashFiles('vcpkg-custom/**', 'vcpkg.json', 'vcpkg-configuration.json') }}
393+
restore-keys: |
394+
vcpkg-cache-${{ runner.os }}-${{ matrix.arch }}-
395395
396396
- name: Build
397397
run: |
@@ -419,6 +419,14 @@ jobs:
419419
mkdir gen/artifacts
420420
mv gen/Release/*.pkg gen/artifacts
421421
422+
- name: Save vcpkg cache
423+
uses: actions/cache/save@v4
424+
# Saves if the key changed (hashes on vcpkg/**, vcpkg.json, vcpkg-configuration.json)
425+
if: steps.restore-vcpkg-cache.outputs.cache-hit != 'true'
426+
with:
427+
path: ~/.cache/vcpkg/archives
428+
key: ${{ steps.restore-vcpkg-cache.outputs.cache-primary-key }}
429+
422430
- name: Upload installer
423431
uses: actions/upload-artifact@v4
424432
with:

0 commit comments

Comments
 (0)