2177f181ed
Stage build/dist/OpenZenLoader.exe and build/libs/hey-1.0.jar into build/release as OpenZenLoader-<sha>.exe and OpenZen-<sha>.jar, then publish each as its own upload-artifact entry whose name matches the file. actions/upload-artifact always wraps a zip around the payload, so this is as close as we can get to "no wrapper" without cutting a Release - documented inline. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
159 lines
6.0 KiB
YAML
159 lines
6.0 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.
|
|
#
|
|
# We rely on actions/cache for the installed Qt artifacts; the
|
|
# vcpkg x-gha backend depends on the v1 GitHub Actions cache API
|
|
# which has been deprecated, and a fresh runner image often does
|
|
# not have ACTIONS_RESULTS_URL set for non-Node actions yet.
|
|
# Setting "files" as the binary source means vcpkg will still
|
|
# populate ${VCPKG_ROOT}/archives, which actions/cache then
|
|
# snapshots along with installed/.
|
|
VCPKG_BINARY_SOURCES: "clear;files,${{ github.workspace }}\\vcpkg-archives,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
|
|
|
|
- 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"
|
|
|
|
# Cache the resolved Qt install + the file-backed binary archive.
|
|
# Key is keyed on vcpkg.json so any dependency change invalidates;
|
|
# restore-keys lets a vcpkg.json bump still warm-start from the
|
|
# previous build's archives. installed/ alone makes CMake's manifest
|
|
# mode skip rebuilding qtbase; archives/ also fills back transitive
|
|
# deps if a partial rebuild is needed.
|
|
- name: Cache vcpkg installed + archives
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: |
|
|
vcpkg\installed
|
|
vcpkg-archives
|
|
key: vcpkg-qt-${{ runner.os }}-${{ hashFiles('native/vcpkg.json') }}
|
|
restore-keys: |
|
|
vcpkg-qt-${{ runner.os }}-
|
|
|
|
- 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
|
|
|
|
# Rename the two distributable artifacts so their final filenames carry
|
|
# the build sha. We rename rather than re-publish at build time so the
|
|
# local `./gradlew dll` workflow keeps producing stable filenames.
|
|
- name: Stage release artifacts
|
|
shell: pwsh
|
|
run: |
|
|
$sha = "${{ steps.rev.outputs.sha }}"
|
|
$exeSrc = "build\dist\OpenZenLoader.exe"
|
|
$jarSrc = "build\libs\hey-1.0.jar"
|
|
if (-not (Test-Path $exeSrc)) { throw "missing $exeSrc" }
|
|
if (-not (Test-Path $jarSrc)) { throw "missing $jarSrc" }
|
|
|
|
$release = "build\release"
|
|
New-Item -ItemType Directory -Force -Path $release | Out-Null
|
|
$exeDst = Join-Path $release "OpenZenLoader-$sha.exe"
|
|
$jarDst = Join-Path $release "OpenZen-$sha.jar"
|
|
Copy-Item -Force $exeSrc $exeDst
|
|
Copy-Item -Force $jarSrc $jarDst
|
|
|
|
$exeSz = (Get-Item $exeDst).Length
|
|
$jarSz = (Get-Item $jarDst).Length
|
|
Write-Host ("OpenZenLoader-{0}.exe : {1:N0} bytes ({2:N2} MB)" -f $sha, $exeSz, ($exeSz/1MB))
|
|
Write-Host ("OpenZen-{0}.jar : {1:N0} bytes ({2:N2} MB)" -f $sha, $jarSz, ($jarSz/1MB))
|
|
|
|
# NOTE: actions/upload-artifact always wraps its content in a zip; that
|
|
# is a platform limitation we cannot disable. By giving each artifact a
|
|
# single file whose name already encodes the sha, the download is
|
|
# OpenZenLoader-<sha>.exe.zip / OpenZen-<sha>.jar.zip, each containing
|
|
# just the named file (no nested directory). For raw exe/jar downloads
|
|
# without the zip wrapper, attach to a GitHub Release instead.
|
|
- name: Upload OpenZenLoader exe
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: OpenZenLoader-${{ steps.rev.outputs.sha }}.exe
|
|
path: build/release/OpenZenLoader-${{ steps.rev.outputs.sha }}.exe
|
|
if-no-files-found: error
|
|
retention-days: 30
|
|
|
|
- name: Upload OpenZen jar
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: OpenZen-${{ steps.rev.outputs.sha }}.jar
|
|
path: build/release/OpenZen-${{ steps.rev.outputs.sha }}.jar
|
|
if-no-files-found: error
|
|
retention-days: 30
|