Skip to content

Commit 263ee4d

Browse files
committed
🔨 Cache vcpkg binaries
1 parent 2489891 commit 263ee4d

4 files changed

Lines changed: 73 additions & 7 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: 'Configure vcpkg with NuGet Cache'
2+
description: 'Bootstraps vcpkg and configures NuGet for binary caching'
3+
inputs:
4+
github_token:
5+
description: 'GitHub Token for NuGet authentication'
6+
required: true
7+
arch:
8+
description: "Architecture to build for"
9+
required: true
10+
runs:
11+
using: "composite"
12+
steps:
13+
- uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756
14+
with:
15+
arch: ${{ inputs.arch }}
16+
- name: Bootstrap vcpkg
17+
shell: pwsh
18+
run: ./third-party/vcpkg/bootstrap-vcpkg.bat
19+
- name: Configure vcpkg nuget cache
20+
shell: pwsh
21+
run: |
22+
$nuget_exe = (./third-party/vcpkg/vcpkg fetch nuget)
23+
$nuget_feed_url = "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
24+
"VCPKG_BINARY_SOURCES=clear;nuget,$nuget_feed_url,readwrite" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
25+
26+
& $nuget_exe sources add `
27+
-Source "$nuget_feed_url" `
28+
-StorePasswordInClearText `
29+
-Name GitHubPackages `
30+
-UserName "${{ github.repository_owner }}" `
31+
-Password "${{ inputs.github_token }}"
32+
& $nuget_exe setapikey "${{ inputs.github_token }}" `
33+
-Source "$nuget_feed_url"

‎.github/workflows/build.yml‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,17 @@ jobs:
1010
name: build/${{matrix.arch}}/${{matrix.preset}}
1111
runs-on: windows-latest
1212
steps:
13-
- name: Set up visual studio environment
14-
uses: ilammy/msvc-dev-cmd@v1
15-
with:
16-
arch: ${{matrix.arch}}
1713
- uses: actions/checkout@v6
1814
with:
1915
submodules: true
2016
fetch-depth: 0
17+
- name: Setup environment
18+
uses: ./.github/actions/configure-environment
19+
with:
20+
arch: ${{matrix.arch}}
21+
github_token: ${{secrets.GITHUB_TOKEN}}
2122
- name: Make build directory
2223
run: cmake -E make_directory build
23-
- name: "Initialize vcpkg"
24-
working-directory: build
25-
run: ../third-party/vcpkg/bootstrap-vcpkg.bat
2624
- name: Configure
2725
working-directory: build
2826
id: configure

‎.github/workflows/ci.yml‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
name: Continuous Integration
22
on: [push, pull_request]
3+
permissions:
4+
packages: write
35
jobs:
6+
populate-vcpkg-cache:
7+
name: Populate vcpkg cache
8+
uses: ./.github/workflows/populate-vcpkg-cache.yaml
9+
secrets: inherit
10+
with:
11+
arch: ${{matrix.arch}}
12+
strategy:
13+
matrix:
14+
arch: [x86, x64]
415
build:
16+
needs: populate-vcpkg-cache
517
name: Build
618
uses: ./.github/workflows/build.yml
719
secrets: inherit
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Populate vcpkg cache
2+
on:
3+
workflow_call:
4+
inputs:
5+
arch:
6+
required: true
7+
type: string
8+
permissions:
9+
packages: write
10+
jobs:
11+
populate:
12+
runs-on: windows-2022
13+
steps:
14+
- uses: actions/checkout@v6
15+
with:
16+
submodules: true
17+
fetch-depth: 0
18+
- uses: ./.github/actions/configure-environment
19+
with:
20+
arch: ${{inputs.arch}}
21+
github_token: ${{secrets.GITHUB_TOKEN}}
22+
- name: Cache vcpkg artifacts
23+
run: third-party/vcpkg/vcpkg install --triplet ${{inputs.arch}}-windows-static

0 commit comments

Comments
 (0)