Skip to content

Commit d5073aa

Browse files
committed
add vcpkg github package caching
1 parent 7d307cd commit d5073aa

1 file changed

Lines changed: 32 additions & 14 deletions

File tree

.github/workflows/build-natives.yml

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,8 @@ jobs:
9090
VCPKG_ROOT: ${{ github.workspace }}/Natives/NetCord.Natives/vcpkg
9191
VcpkgOSTarget: ${{ matrix.vcpkg-os-target }}
9292
VcpkgPlatformTarget: ${{ matrix.vcpkg-platform-target }}
93-
FEED_URL: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
93+
GITHUB_PACKAGES_FEED: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
9494
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite"
95-
VCPKG_NUGET_REPOSITORY: https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json
96-
INPUT_TOKEN: ${{ secrets.VCPKG_NUGET_TOKEN }}
9795
Configuration: Release
9896
TargetRID: ${{ matrix.rid }}
9997
DotnetVerbose: ${{ github.event.inputs.MSBuildVerbosity || inputs.MSBuildVerbosity || 'Minimal' }}
@@ -121,23 +119,43 @@ jobs:
121119

122120
- name: Setup vcpkg (Windows)
123121
if: ${{ !matrix.use-nix }}
122+
shell: pwsh
124123
run: |
125-
& "$env:VCPKG_ROOT\bootstrap-vcpkg.bat" -disableMetrics
124+
& "${{ env.VCPKG_ROOT }}\bootstrap-vcpkg.bat" -disableMetrics
126125
127-
- name: Configure Github NuGet Vcpkg Cache (Windows)
128-
if: ${{ !matrix.use-nix }}
129-
run: >
130-
dotnet nuget add source "${{ env.FEED_URL }}"
131-
--name "GitHubPackages"
132-
-u "${{ github.repository_owner }}"
133-
-p "${{ secrets.VCPKG_NUGET_TOKEN }}"
134-
--store-password-in-clear-text
135-
--configfile "$env:APPDATA\NuGet\NuGet.Config" || true
126+
# Fetch the nuget path, filter out any warning lines, and run it
127+
$nugetPath = & "${{ env.VCPKG_ROOT }}\vcpkg" fetch nuget | Select-Object -Last 1
128+
129+
& $nugetPath sources add `
130+
-Source "${{ env.GITHUB_PACKAGES_FEED }}" `
131+
-Name "GithubPackages" `
132+
-UserName "${{ github.repository_owner }}" `
133+
-Password "${{ secrets.VCPKG_NUGET_TOKEN }}" `
134+
-StorePasswordInClearText
135+
136+
# Set the api key for the GitHub Packages feed
137+
& $nugetPath setapikey "${{ secrets.VCPKG_NUGET_TOKEN }}" `
138+
-Source "${{ env.GITHUB_PACKAGES_FEED }}"
136139
137140
- name: Setup vcpkg (Nix)
138141
if: ${{ matrix.use-nix }}
142+
shell: bash
139143
run: |
140-
$VCPKG_ROOT/bootstrap-vcpkg.sh -disableMetrics
144+
"${{ env.VCPKG_ROOT }}/bootstrap-vcpkg.sh" -disableMetrics
145+
146+
# Capture the nuget.exe path to a local variable
147+
NUGET_PATH=$("${{ env.VCPKG_ROOT }}/vcpkg" fetch nuget | tail -n 1)
148+
149+
mono "$NUGET_PATH" sources add \
150+
-Source "${{ env.GITHUB_PACKAGES_FEED }}" \
151+
-Name "GithubPackages" \
152+
-UserName "${{ github.repository_owner }}" \
153+
-Password "${{ secrets.VCPKG_NUGET_TOKEN }}" \
154+
-StorePasswordInClearText
155+
156+
# Set the api key for the GitHub Packages feed
157+
mono "$NUGET_PATH" setapikey "${{ secrets.VCPKG_NUGET_TOKEN }}" \
158+
-Source "${{ env.GITHUB_PACKAGES_FEED }}"
141159
142160
- name: Setup .NET Core SDK (Windows)
143161
if: ${{ !matrix.use-nix }}

0 commit comments

Comments
 (0)