name: Setup vcpkg cache
|
description: Restores the vcpkg cache and saves it only for main branch runs.
|
|
inputs:
|
key:
|
description: Workflow and job-specific cache key component.
|
required: true
|
path:
|
description: Path to the vcpkg cache directory.
|
required: false
|
default: ~/.cache/vcpkg
|
|
runs:
|
using: composite
|
steps:
|
- name: Configure Windows vcpkg binary cache
|
if: runner.os == 'Windows'
|
shell: pwsh
|
env:
|
VCPKG_CACHE_PATH: ${{ inputs.path }}
|
run: |
|
New-Item -ItemType Directory -Path $env:VCPKG_CACHE_PATH -Force | Out-Null
|
"VCPKG_DEFAULT_BINARY_CACHE=$env:VCPKG_CACHE_PATH" |
|
Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
- name: Restore and save vcpkg cache
|
if: github.ref == 'refs/heads/main'
|
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
|
with:
|
key: >-
|
vcpkg-cache-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.key }}-${{
|
hashFiles(
|
'cmake/vcpkg.json',
|
'cmake/vcpkg-configuration.json',
|
'cmake/vcpkg-ports/**',
|
'tools/ci_build/vcpkg_tool_info.json',
|
'tools/python/util/vcpkg_helpers.py'
|
)
|
}}
|
restore-keys: |
|
vcpkg-cache-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.key }}-
|
path: ${{ inputs.path }}
|
|
- name: Restore vcpkg cache
|
if: github.ref != 'refs/heads/main'
|
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
|
with:
|
key: >-
|
vcpkg-cache-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.key }}-${{
|
hashFiles(
|
'cmake/vcpkg.json',
|
'cmake/vcpkg-configuration.json',
|
'cmake/vcpkg-ports/**',
|
'tools/ci_build/vcpkg_tool_info.json',
|
'tools/python/util/vcpkg_helpers.py'
|
)
|
}}
|
restore-keys: |
|
vcpkg-cache-v2-${{ runner.os }}-${{ runner.arch }}-${{ inputs.key }}-
|
path: ${{ inputs.path }}
|