diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index 6b19e968769..4fb5b9ef91f 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -3,6 +3,7 @@ name: Build Toolchain permissions: contents: read pull-requests: write + packages: write on: workflow_call: @@ -33,8 +34,8 @@ jobs: timeout-minutes: 30 env: - VCPKG_FILE_CACHE: ${{ github.workspace }}\vcpkg-bincache - VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-bincache,readwrite + VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json,readwrite" + VCPKG_NUGET_REPOSITORY: "https://github.com/${{ github.repository }}.git" VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching steps: @@ -105,51 +106,25 @@ jobs: with: arch: x86 - - name: Compute vcpkg cache key parts - if: startsWith(inputs.preset, 'win32') - id: vcpkg_key - shell: pwsh - run: | - $baseline = (Get-Content vcpkg.json | ConvertFrom-Json)."builtin-baseline" - - $triplet = "x86-windows" - if ("${{ inputs.preset }}" -like "x64*") { $triplet = "x64-windows" } - - "baseline=$baseline" >> $env:GITHUB_OUTPUT - "triplet=$triplet" >> $env:GITHUB_OUTPUT - - Write-Host "vcpkg cache key parts: baseline=$baseline, triplet=$triplet" - - - name: Restore vcpkg binary cache - if: startsWith(inputs.preset, 'win32') - id: vcpkg_cache - uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}\vcpkg-bincache - key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }} - restore-keys: | - vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}- - vcpkg-bincache-v3-${{ runner.os }}- - - name: Setup vcpkg uses: lukka/run-vcpkg@5e0cab206a5ea620130caf672fce3e4a6b5666a1 # v11.5 with: runVcpkgInstall: false doNotCache: true - - name: Configure vcpkg to use cached directory + - name: Configure NuGet Source for vcpkg Binary Cache if: startsWith(inputs.preset, 'win32') shell: pwsh run: | - $cacheDir = "${{ github.workspace }}\vcpkg-bincache" - New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null - - # lukka/run-vcpkg sets its own temp cache dir; override to force our cached dir - $env:VCPKG_DEFAULT_BINARY_CACHE = $cacheDir - $env:VCPKG_BINARY_SOURCES = "clear;files,$cacheDir,readwrite" - - "VCPKG_DEFAULT_BINARY_CACHE=$cacheDir" >> $env:GITHUB_ENV - "VCPKG_BINARY_SOURCES=$env:VCPKG_BINARY_SOURCES" >> $env:GITHUB_ENV + $nuget = & "$env:VCPKG_ROOT\vcpkg.exe" fetch nuget | Select-Object -Last 1 + & $nuget sources add ` + -Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" ` + -StorePasswordInClearText ` + -Name GitHubPackages ` + -UserName "${{ github.repository_owner }}" ` + -Password "${{ secrets.GITHUB_TOKEN }}" + & $nuget setapikey "${{ secrets.GITHUB_TOKEN }}" ` + -Source "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" "VCPKG_OVERLAY_TRIPLETS=${{ github.workspace }}\triplets" >> $env:GITHUB_ENV "VCPKG_INSTALL_OPTIONS=--x-abi-tools-use-exact-versions" >> $env:GITHUB_ENV @@ -175,14 +150,6 @@ jobs: run: | cmake --build --preset ${{ inputs.preset }} - - name: Save vcpkg binary cache - # Only one job should save to avoid "Unable to reserve cache" conflicts. - if: ${{ startsWith(inputs.preset, 'win32') && steps.vcpkg_cache.outputs.cache-hit != 'true' && inputs.game == 'Generals' && inputs.preset == 'win32-vcpkg-debug' }} - uses: actions/cache/save@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3 - with: - path: ${{ github.workspace }}\vcpkg-bincache - key: vcpkg-bincache-v3-${{ runner.os }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }}-${{ hashFiles('triplets/*.cmake') }} - - name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact shell: pwsh run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7069fa9c146..40e438db7a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,6 +3,7 @@ name: GenCI permissions: contents: read pull-requests: write + packages: write on: push: