Skip to content

Commit 2a15e03

Browse files
authored
Add support for GitHub Packages vcpkg cache (#408)
An optional `GH_PACKAGES_FEED` can be specified to setup a NuGet feed using GitHub packages. Also requires a `GH_PACKAGES_USERNAME` and `GH_PACKAGES_TOKEN` to fully use.
1 parent 00f5255 commit 2a15e03

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

buildbot-worker/BuildbotWorker/Run-BuildbotWorker.ps1

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,50 @@ python3 buildbot.py;
9999

100100
Remove-Item Env:BUILD_WORKER_PASSWORD;
101101

102+
# Add NuGet vcpkg feeds
103+
#
104+
# Remove the token environment variable after configuration
105+
# as buildbot will print the entire environment and leak the
106+
# information.
107+
if (Test-Path Env:GH_PACKAGES_FEED) {
108+
if (-not (Test-Path Env:GH_PACKAGES_USERNAME)) {
109+
Write-Error ('WebKit buildbots require a username to connect to a vcpkg feed.
110+
For local development set the GH_PACKAGES_USERNAME environment variable using
111+
docker run -e GH_PACKAGES_USERNAME=<gh-packages-username>');
112+
}
113+
if (Test-Path Env:GH_PACKAGES_TOKEN) {
114+
$ghToken = $Env:GH_PACKAGES_TOKEN;
115+
Remove-Item Env:GH_PACKAGES_TOKEN;
116+
} elseif (Test-Path Env:GH_PACKAGES_TOKEN_FILE) {
117+
Write-Host ('Loading token from {0}',$env:GH_PACKAGES_TOKEN_FILE);
118+
$ghToken = Get-Content -Path $env:GH_PACKAGES_TOKEN_FILE;
119+
} else {
120+
Write-Error ('WebKit buildbots require a token to connect to a vcpkg feed
121+
For local development set the GH_PACKAGES_TOKEN environment variable using
122+
docker run -e GH_PACKAGES_TOKEN=<gh-packages-token>
123+
While in production use docker secrets and set the location of the file using the GH_PACKAGES_TOKEN_FILE environment variable');
124+
}
125+
126+
if (Test-Path Env:GH_PACKAGES_CACHE_TYPE) {
127+
$ghCacheType = $env:GH_PACKAGES_CACHE_TYPE;
128+
} else {
129+
$ghCacheType = 'readwrite';
130+
}
131+
132+
nuget sources add `
133+
-Source $env:GH_PACKAGES_FEED `
134+
-Name GitHubPackages `
135+
-Username $env:GH_PACKAGES_USERNAME `
136+
-Password $ghToken;
137+
138+
nuget setapikey $ghToken -Source $env:GH_PACKAGES_FEED;
139+
140+
Write-Host ('Vcpkg configured to use {0} as a cache with {1} access' -f $env:GH_PACKAGES_FEED,$ghCacheType);
141+
$env:VCPKG_BINARY_SOURCES = ('clear;nuget,{0},{1}' -f $env:GH_PACKAGES_FEED,$ghCacheType);
142+
} else {
143+
Write-Warning ('WebKit buildbot is not using a cache for vcpkg');
144+
}
145+
102146
# Run any additional startup scripts
103147
$scriptPath = Join-Path $PSScriptRoot 'Scripts';
104148

0 commit comments

Comments
 (0)