Skip to content

Commit ea0b7ea

Browse files
authored
Update VCPKG GHAs to use head commit id if variable isn't set (#194)
1 parent 1e6d18c commit ea0b7ea

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

.github/workflows/vcpkg.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,28 @@ jobs:
9393
echo "::error Unknown architecture/build-type triplet mapping"
9494
}
9595
96+
- name: Get vcpkg commit hash
97+
shell: pwsh
98+
run: |
99+
if ($Env:vcpkgRelease) {
100+
echo "Using vcpkg commit from repo variable..."
101+
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
102+
}
103+
else {
104+
echo "Fetching latest vcpkg commit hash..."
105+
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
106+
$VCPKG_COMMIT_ID = $commit
107+
}
108+
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
109+
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
110+
env:
111+
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
112+
96113
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
97114
with:
98115
runVcpkgInstall: true
99116
vcpkgJsonGlob: '**/build/vcpkg.json'
100-
vcpkgGitCommitId: '${{ vars.VCPKG_COMMIT_ID }}'
117+
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
101118

102119
- name: 'Configure CMake'
103120
working-directory: ${{ github.workspace }}

.github/workflows/wsl.yml

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,28 @@ jobs:
3636

3737
- uses: seanmiddleditch/gha-setup-ninja@96bed6edff20d1dd61ecff9b75cc519d516e6401 # v5
3838

39+
- name: Get vcpkg commit hash
40+
shell: pwsh
41+
run: |
42+
if ($Env:vcpkgRelease) {
43+
echo "Using vcpkg commit from repo variable..."
44+
$VCPKG_COMMIT_ID = $Env:vcpkgRelease
45+
}
46+
else {
47+
echo "Fetching latest vcpkg commit hash..."
48+
$commit = (git ls-remote https://github.com/microsoft/vcpkg.git HEAD | Select-String -Pattern '([a-f0-9]{40})').Matches.Value
49+
$VCPKG_COMMIT_ID = $commit
50+
}
51+
Write-Host "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID"
52+
echo "VCPKG_COMMIT_ID=$VCPKG_COMMIT_ID" >> $env:GITHUB_ENV
53+
env:
54+
vcpkgRelease: '${{ vars.VCPKG_COMMIT_ID }}'
55+
3956
- uses: lukka/run-vcpkg@7d259227a1fb6471a0253dd5ab7419835228f7d7 # v11
4057
with:
4158
runVcpkgInstall: true
4259
vcpkgJsonGlob: '**/build/vcpkg.json'
43-
vcpkgGitCommitId: '${{ vars.VCPKG_COMMIT_ID }}'
60+
vcpkgGitCommitId: '${{ env.VCPKG_COMMIT_ID }}'
4461

4562
- name: 'Configure CMake'
4663
working-directory: ${{ github.workspace }}

0 commit comments

Comments
 (0)