windows-2022 runners with VS Enterprise installed pre-set a system-wide VCPKG_ROOT pointing at "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\vcpkg". That value wins over the job-level `env: VCPKG_ROOT:` in PowerShell expansions, so the previous run tried to git-clone into that read-only path and failed with "destination path ... already exists and is not an empty directory". Drop the job-level VCPKG_ROOT and instead resolve the path to "$GITHUB_WORKSPACE\vcpkg" inside the clone step, then write it back via GITHUB_ENV so every later step (including Gradle's findVcpkg / configureNative) picks up our copy. The build step also dumps VCPKG_ROOT / JAVA_HOME / OPENZEN_BUILD_REVISION up front for quick diagnosis if the override ever drifts again. Co-Authored-By: Claude Opus 4.7 <[email protected]>
116 lines
3.8 KiB
YAML
116 lines
3.8 KiB
YAML
name: Build Loader
|
|
|
|
on:
|
|
push:
|
|
branches: [master]
|
|
workflow_dispatch: {}
|
|
|
|
# Needed for vcpkg's GitHub Actions binary cache (x-gha backend).
|
|
permissions:
|
|
contents: read
|
|
actions: write
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-2022
|
|
timeout-minutes: 180
|
|
|
|
env:
|
|
# NOTE: do not declare VCPKG_ROOT here. The windows-2022 runner
|
|
# ships VS Enterprise which pre-sets a system-wide VCPKG_ROOT
|
|
# pointing at its own (empty) vcpkg dir, and that pre-set value
|
|
# wins over a job-level env in PowerShell expansions. We export
|
|
# the right VCPKG_ROOT into $GITHUB_ENV inside the clone step
|
|
# so every later step sees our copy.
|
|
VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite"
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 1
|
|
|
|
- name: Resolve git revision
|
|
id: rev
|
|
shell: pwsh
|
|
run: |
|
|
$sha = git rev-parse --short=7 HEAD
|
|
"sha=$sha" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
|
|
Write-Host "Build revision: $sha"
|
|
|
|
- name: Setup JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: 17
|
|
|
|
- name: Setup MSVC (x64)
|
|
uses: ilammy/msvc-dev-cmd@v1
|
|
with:
|
|
arch: x64
|
|
|
|
# Expose ACTIONS_CACHE_URL / ACTIONS_RUNTIME_TOKEN to subsequent
|
|
# steps so vcpkg's x-gha cache backend works. These are set by
|
|
# the runner but only exposed to actions via the toolkit; we
|
|
# forward them manually for the shell-based vcpkg calls below.
|
|
- name: Export GitHub Actions cache tokens
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
|
|
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
|
|
|
|
- name: Clone & bootstrap vcpkg
|
|
shell: pwsh
|
|
run: |
|
|
$vcpkg = Join-Path $env:GITHUB_WORKSPACE 'vcpkg'
|
|
if (Test-Path $vcpkg) {
|
|
Write-Host "Reusing existing $vcpkg"
|
|
} else {
|
|
git clone --depth=1 https://github.com/microsoft/vcpkg.git $vcpkg
|
|
}
|
|
& "$vcpkg\bootstrap-vcpkg.bat" -disableMetrics
|
|
& "$vcpkg\vcpkg.exe" version
|
|
"VCPKG_ROOT=$vcpkg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
|
|
Write-Host "Exported VCPKG_ROOT=$vcpkg to GITHUB_ENV"
|
|
|
|
- name: Install UPX
|
|
shell: pwsh
|
|
run: choco install upx -y --no-progress
|
|
|
|
- name: Cache Gradle
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle', '**/gradle-wrapper.properties') }}
|
|
restore-keys: |
|
|
gradle-${{ runner.os }}-
|
|
|
|
- name: Build (clean dll upxCompress)
|
|
shell: pwsh
|
|
env:
|
|
OPENZEN_BUILD_REVISION: ${{ steps.rev.outputs.sha }}
|
|
run: |
|
|
Write-Host "VCPKG_ROOT = $env:VCPKG_ROOT"
|
|
Write-Host "JAVA_HOME = $env:JAVA_HOME"
|
|
Write-Host "OPENZEN_BUILD_REV = $env:OPENZEN_BUILD_REVISION"
|
|
.\gradlew.bat --no-daemon clean dll upxCompress
|
|
|
|
- name: Show artifact info
|
|
shell: pwsh
|
|
run: |
|
|
$exe = "build\dist\OpenZenLoader.exe"
|
|
if (-not (Test-Path $exe)) { throw "missing $exe" }
|
|
$sz = (Get-Item $exe).Length
|
|
Write-Host ("OpenZenLoader.exe: {0:N0} bytes ({1:N2} MB)" -f $sz, ($sz/1MB))
|
|
|
|
- name: Upload OpenZenLoader.exe
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: OpenZenLoader-${{ steps.rev.outputs.sha }}
|
|
path: build/dist/OpenZenLoader.exe
|
|
if-no-files-found: error
|
|
retention-days: 30
|