Skip to content

Commit 11e489d

Browse files
author
codethinki
committed
trying to cache vcpkg better on windows
1 parent 8e1417f commit 11e489d

1 file changed

Lines changed: 34 additions & 10 deletions

File tree

.github/actions/setup-windows/action.yml

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,46 @@ runs:
4646
restore-keys: |
4747
buildcache-windows-${{ inputs.compiler }}-
4848
49-
- name: Cache Custom Vcpkg
50-
id: cache-vcpkg-custom
51-
uses: actions/cache@v4
49+
- name: Restore Custom Vcpkg
50+
id: restore-vcpkg
51+
uses: actions/cache/restore@v4
5252
with:
5353
path: c:\vcpkg-custom
54-
key: vcpkg-custom-repo-windows
54+
key: vcpkg-custom-repo-windows-restore-search
55+
restore-keys: |
56+
vcpkg-custom-repo-windows-
5557
56-
- name: Setup Vcpkg (Latest)
58+
- name: Setup Vcpkg (Clone/Update)
5759
shell: pwsh
5860
run: |
59-
if (!(Test-Path "c:\vcpkg-custom\.git")) {
60-
git clone https://github.com/microsoft/vcpkg.git c:\vcpkg-custom
61+
$vcpkgPath = "c:\vcpkg-custom"
62+
if (!(Test-Path "$vcpkgPath\.git")) {
63+
Write-Host "Cloning vcpkg..."
64+
git clone https://github.com/microsoft/vcpkg.git $vcpkgPath
65+
} else {
66+
Write-Host "Fetching vcpkg updates..."
67+
Push-Location $vcpkgPath
68+
git fetch origin master
69+
git pull origin master
70+
Pop-Location
6171
}
62-
& "c:\vcpkg-custom\bootstrap-vcpkg.bat" -disableMetrics
63-
echo "VCPKG_ROOT=c:\vcpkg-custom" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
64-
echo "c:\vcpkg-custom" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
72+
73+
Push-Location $vcpkgPath
74+
$sha = git rev-parse HEAD
75+
Pop-Location
76+
"VCPKG_SHA=$sha" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
77+
78+
& "$vcpkgPath\bootstrap-vcpkg.bat" -disableMetrics
79+
80+
echo "VCPKG_ROOT=$vcpkgPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
81+
echo "$vcpkgPath" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
82+
83+
- name: Save Custom Vcpkg (New State)
84+
if: steps.restore-vcpkg.outputs.cache-matched-key != format('vcpkg-custom-repo-windows-{0}', env.VCPKG_SHA)
85+
uses: actions/cache/save@v4
86+
with:
87+
path: c:\vcpkg-custom
88+
key: vcpkg-custom-repo-windows-${{ env.VCPKG_SHA }}
6589

6690
- name: Install BuildCache
6791
shell: pwsh

0 commit comments

Comments
 (0)