Skip to content

Commit 4b9e729

Browse files
authored
Merge pull request #293 from wravery/main
Make workflows work with vcpkg binary artifact caching
2 parents 1d65922 + e50691f commit 4b9e729

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.github/workflows/macos.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,14 @@ jobs:
2020
uses: actions/cache@v3
2121
id: cache-vcpkg
2222
with:
23-
path: build/vcpkg_installed/
24-
key: vcpkg-x64-osx
23+
path: build/vcpkg_cache/
24+
key: vcpkg-binaries-x64-osx
2525

2626
- name: Create Build Environment
2727
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
28-
run: cmake -E make_directory build
28+
run: |
29+
cmake -E make_directory build
30+
cmake -E make_directory build/vcpkg_cache
2931
3032
- name: Configure
3133
shell: pwsh
@@ -34,6 +36,10 @@ jobs:
3436
$vcpkgToolchain = Join-Path $env:VCPKG_INSTALLATION_ROOT './scripts/buildsystems/vcpkg.cmake' -Resolve
3537
$cmakeBuildType = '${{ matrix.config }}'
3638
39+
$cachedBinaries = Join-Path $(Get-Location) './vcpkg_cache/' -Resolve
40+
$cacheAccess = $(if ('${{ steps.cache-vcpkg.outputs.cache-hit }}' -eq 'true') { 'read' } else { 'write' })
41+
$env:VCPKG_BINARY_SOURCES = "clear;files,$cachedBinaries,$cacheAccess"
42+
3743
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DCMAKE_BUILD_TYPE=$cmakeBuildType" ${{ github.workspace }}
3844
3945
- name: Build

.github/workflows/windows.yml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ jobs:
2727
uses: actions/cache@v3
2828
id: cache-vcpkg
2929
with:
30-
path: build/vcpkg_installed/
31-
key: vcpkg-${{ steps.set-variables.outputs.vcpkg_triplet }}
30+
path: build/vcpkg_cache/
31+
key: vcpkg-binaries-${{ steps.set-variables.outputs.vcpkg_triplet }}
3232

3333
- name: Create Build Environment
3434
if: ${{ !steps.cache-vcpkg.outputs.cache-hit }}
35-
run: cmake -E make_directory build
35+
run: |
36+
cmake -E make_directory build
37+
cmake -E make_directory build/vcpkg_cache
3638
3739
- name: Configure
3840
shell: pwsh
@@ -43,6 +45,10 @@ jobs:
4345
$cmakeSharedLibs = $(if ('${{ matrix.libs }}' -eq 'shared') { 'ON' } else { 'OFF' })
4446
$msbuildArch = $(if ('${{ matrix.arch }}' -eq 'x64') { 'X64' } else { 'Win32' })
4547
48+
$cachedBinaries = Join-Path $(Get-Location) './vcpkg_cache/' -Resolve
49+
$cacheAccess = $(if ('${{ steps.cache-vcpkg.outputs.cache-hit }}' -eq 'true') { 'read' } else { 'write' })
50+
$env:VCPKG_BINARY_SOURCES = "clear;files,$cachedBinaries,$cacheAccess"
51+
4652
cmake "-DCMAKE_TOOLCHAIN_FILE=$vcpkgToolchain" "-DVCPKG_TARGET_TRIPLET=$vcpkgTriplet" "-DBUILD_SHARED_LIBS=$cmakeSharedLibs" -G "Visual Studio 17 2022" -A "$msbuildArch" ${{ github.workspace }}
4753
4854
- name: Build

0 commit comments

Comments
 (0)