Skip to content

Commit 1273687

Browse files
authored
Merge pull request #11 from 3dJan/3dJan/vcpkg_binary_cache
3d jan/vcpkg binary cache
2 parents 0be18da + a89f2c7 commit 1273687

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

.github/workflows/build.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,15 @@ on:
1212
workflow_dispatch:
1313
workflow_call: # Allow this workflow to be called by other workflows
1414

15+
permissions:
16+
packages: write # Required for vcpkg binary caching with GitHub Packages
17+
1518
jobs:
1619
build:
1720
runs-on: ${{ matrix.os }}
21+
22+
env:
23+
VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite"
1824

1925
strategy:
2026
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
@@ -89,6 +95,75 @@ jobs:
8995
run: ./bootstrap-vcpkg.bat
9096
working-directory: ${{ github.workspace }}/vcpkg
9197

98+
- name: Install mono for NuGet (Linux)
99+
if: runner.os != 'Windows'
100+
run: sudo apt-get install -y mono-complete
101+
102+
- name: Install buildcache (Linux)
103+
if: runner.os != 'Windows'
104+
run: |
105+
wget https://github.com/mbitsnbites/buildcache/releases/download/v0.28.1/buildcache-linux.tar.gz
106+
tar -xzf buildcache-linux.tar.gz
107+
sudo cp buildcache/bin/buildcache /usr/local/bin/
108+
buildcache --version
109+
110+
- name: Install buildcache (Windows)
111+
if: runner.os == 'Windows'
112+
shell: pwsh
113+
run: |
114+
Invoke-WebRequest -Uri "https://github.com/mbitsnbites/buildcache/releases/download/v0.28.1/buildcache-windows.zip" -OutFile "buildcache.zip"
115+
Expand-Archive -Path "buildcache.zip" -DestinationPath "buildcache" -Force
116+
Copy-Item -Path "buildcache\buildcache\bin\buildcache.exe" -Destination "C:\Windows\System32\buildcache.exe" -Force
117+
buildcache --version
118+
119+
- name: Cache buildcache (Linux)
120+
if: runner.os != 'Windows'
121+
uses: actions/cache@v4
122+
with:
123+
path: ~/.buildcache
124+
key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ github.sha }}
125+
restore-keys: |
126+
buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-
127+
128+
- name: Cache buildcache (Windows)
129+
if: runner.os == 'Windows'
130+
uses: actions/cache@v4
131+
with:
132+
path: ~\AppData\Local\buildcache
133+
key: buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-${{ github.sha }}
134+
restore-keys: |
135+
buildcache-${{ matrix.os }}-${{ matrix.c_compiler }}-
136+
137+
- name: Setup NuGet authentication for vcpkg binary caching (Linux)
138+
if: runner.os != 'Windows'
139+
shell: bash
140+
run: |
141+
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
142+
sources add \
143+
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" \
144+
-StorePasswordInClearText \
145+
-Name GitHubPackages \
146+
-UserName "${{ github.repository_owner }}" \
147+
-Password "${{ secrets.GITHUB_TOKEN }}"
148+
mono `${{ github.workspace }}/vcpkg/vcpkg fetch nuget | tail -n 1` \
149+
setapikey "${{ secrets.GITHUB_TOKEN }}" \
150+
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
151+
152+
- name: Setup NuGet authentication for vcpkg binary caching (Windows)
153+
if: runner.os == 'Windows'
154+
shell: pwsh
155+
run: |
156+
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
157+
sources add `
158+
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" `
159+
-StorePasswordInClearText `
160+
-Name GitHubPackages `
161+
-UserName "${{ github.repository_owner }}" `
162+
-Password "${{ secrets.GITHUB_TOKEN }}"
163+
& "$(${{ github.workspace }}/vcpkg/vcpkg fetch nuget)" `
164+
setapikey "${{ secrets.GITHUB_TOKEN }}" `
165+
-Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
166+
92167
- name: Set reusable strings
93168
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
94169
id: strings
@@ -104,6 +179,7 @@ jobs:
104179
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
105180
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
106181
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
182+
-DUSE_CACHE=ON
107183
-G Ninja
108184
-S ${{ github.workspace }}/gladius
109185
env:

0 commit comments

Comments
 (0)