feat: Enhance Windows build and release workflows with packaging and validation for CUDA runtime libraries
Some checks failed
Build Windows Avalonia / build (push) Failing after 2m26s

This commit is contained in:
Maddo 2026-12-03 20:06:06 +01:00
commit a883daf068
4 changed files with 107 additions and 20 deletions

View file

@ -71,6 +71,8 @@ jobs:
- name: Publish Windows Avalonia build
run: |
set -eu
publish_dir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}"
rm -rf "${publish_dir}"
dotnet publish "${{ env.PROJECT_PATH }}" \
-c Release \
-r win-x64 \
@ -80,7 +82,7 @@ jobs:
-p:PublishSingleFile=true \
-p:PublishTrimmed=false \
-p:PublishReadyToRun=false \
-o "${{ env.PUBLISH_DIR }}"
-o "${publish_dir}"
- name: Validate published executable
run: |
@ -98,6 +100,13 @@ jobs:
exit 1
fi
- name: Validate AI runtime libraries
run: |
set -eu
dotnet msbuild "${{ env.PROJECT_PATH }}" \
-target:ValidateWindowsCatalogPublishOutput \
-p:PublishDir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}"
- name: Upload publish artifact
uses: actions/upload-artifact@v3
with:

View file

@ -9,6 +9,7 @@ env:
DOTNET_VERSION: 10.0.x
PROJECT_PATH: imagecatalog/ImageCatalog 2.csproj
PUBLISH_DIR: artifacts/publish/win-x64
PACKAGE_PATH: artifacts/publish/ImageCatalog-avalonia-win-x64.zip
ARTIFACT_NAME: imagecatalog-windows-avalonia
NUGET_SOURCE_NAME: Nuget-Forgejo-AIFotoONLUS
NUGET_SOURCE_URL: ${{ vars.AIFOTOONLUS_NUGET_SOURCE_URL || format('{0}/api/packages/{1}/nuget/index.json', forgejo.server_url, vars.AIFOTOONLUS_PACKAGE_OWNER || forgejo.repository_owner) }}
@ -62,6 +63,8 @@ jobs:
- name: Publish Windows Avalonia build
run: |
set -eu
publish_dir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}"
rm -rf "${publish_dir}"
dotnet publish "${{ env.PROJECT_PATH }}" \
-c Release \
-r win-x64 \
@ -71,7 +74,7 @@ jobs:
-p:PublishSingleFile=true \
-p:PublishTrimmed=false \
-p:PublishReadyToRun=false \
-o "${{ env.PUBLISH_DIR }}"
-o "${publish_dir}"
- name: Validate published executable
run: |
@ -89,11 +92,20 @@ jobs:
exit 1
fi
- name: Package complete Windows release
run: |
set -eu
dotnet msbuild "${{ env.PROJECT_PATH }}" \
-target:PackageWindowsCatalogOutput \
-p:PublishDir="${GITHUB_WORKSPACE}/${{ env.PUBLISH_DIR }}" \
-p:PublishArchivePath="${GITHUB_WORKSPACE}/${{ env.PACKAGE_PATH }}"
test -s "${GITHUB_WORKSPACE}/${{ env.PACKAGE_PATH }}"
- name: Upload publish artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.PUBLISH_DIR }}
path: ${{ env.PACKAGE_PATH }}
if-no-files-found: error
release:
@ -153,22 +165,22 @@ jobs:
echo "RELEASE_ID=${release_id}" >> "${GITHUB_ENV}"
- name: Upload executable to release
- name: Upload Windows distributable ZIP to release
run: |
set -eu
api_base="${FORGEJO_SERVER_URL%/}/api/v1/repos/${FORGEJO_REPOSITORY}"
executable_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.exe' | head -n1)"
archive_path="$(find artifacts/release -maxdepth 1 -type f -iname '*.zip' | head -n1)"
if [ -z "${executable_path}" ]; then
echo "No executable found in downloaded artifact"
if [ -z "${archive_path}" ]; then
echo "No Windows distributable ZIP found in downloaded artifact"
exit 1
fi
short_sha="$(printf '%s' "${FORGEJO_SHA}" | cut -c1-12)"
asset_name="ImageCatalog-avalonia-win-x64-${FORGEJO_REF_NAME}-${short_sha}.exe"
asset_name="ImageCatalog-avalonia-win-x64-${FORGEJO_REF_NAME}-${short_sha}.zip"
curl -fsS \
-H "Authorization: token ${FORGEJO_TOKEN}" \
-H "Content-Type: application/octet-stream" \
--data-binary @"${executable_path}" \
--data-binary @"${archive_path}" \
"${api_base}/releases/${RELEASE_ID}/assets?name=${asset_name}"

View file

@ -85,16 +85,28 @@ build_windows:
}
& $dotnetExe restore
& $dotnetExe build "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -v minimal
# Produce a single-file, ready-to-run publish so downstream jobs only need the EXE.
# Publish a single-file executable with the CUDA/OpenCV runtime libraries alongside it.
try {
& $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -p:PublishReadyToRun=true -o "imagecatalog\bin\$env:BUILD_CONFIG\net10.0-windows\publish" -v minimal
$publishDir = "imagecatalog\bin\$env:BUILD_CONFIG\net10.0-windows\publish"
$legacyRendererFiles = Get-ChildItem $publishDir -File | Where-Object { $_.Name -in @('Microsoft.Windows.Compatibility.dll', 'System.Private.Windows.GdiPlus.dll') }
$archivePath = Join-Path (Split-Path $publishDir -Parent) 'ImageCatalog-avalonia-win-x64.zip'
$publishDirAbsolute = [System.IO.Path]::GetFullPath($publishDir)
$archivePathAbsolute = [System.IO.Path]::GetFullPath($archivePath)
if (Test-Path $publishDirAbsolute) {
Remove-Item -LiteralPath $publishDirAbsolute -Recurse -Force
}
if (Test-Path $archivePathAbsolute) {
Remove-Item -LiteralPath $archivePathAbsolute -Force
}
& $dotnetExe publish "imagecatalog\ImageCatalog 2.csproj" -c $env:BUILD_CONFIG -r win-x64 --self-contained true -p:PublishSingleFile=true -p:PublishTrimmed=false -p:PublishReadyToRun=true -o $publishDirAbsolute -v minimal
if ($LASTEXITCODE -ne 0) { throw 'dotnet publish failed' }
$legacyRendererFiles = Get-ChildItem $publishDirAbsolute -File | Where-Object { $_.Name -in @('Microsoft.Windows.Compatibility.dll', 'System.Private.Windows.GdiPlus.dll') }
if ($legacyRendererFiles) {
Write-Host 'Legacy GDI compatibility assemblies must not be published:'
$legacyRendererFiles | ForEach-Object { Write-Host $_.FullName }
exit 1
}
& $dotnetExe msbuild "imagecatalog\ImageCatalog 2.csproj" -target:PackageWindowsCatalogOutput "-p:PublishDir=$publishDirAbsolute" "-p:PublishArchivePath=$archivePathAbsolute"
if ($LASTEXITCODE -ne 0) { throw 'Failed to package the Windows Catalog output' }
} catch {
Write-Host "dotnet publish failed: $_"
throw
@ -102,7 +114,7 @@ build_windows:
}
artifacts:
paths:
- "imagecatalog/bin/$BUILD_CONFIG/net10.0-windows/publish/**"
- "imagecatalog/bin/$BUILD_CONFIG/net10.0-windows/ImageCatalog-avalonia-win-x64.zip"
expire_in: 1 hour
# Publish and create GitLab Release when building a tag.
@ -128,17 +140,16 @@ publish_release:
if [ -z "$version" ]; then echo "minver failed to produce a version"; exit 1; fi
echo "Using version: $version"
export VERSION="$version"
# find the single-file exe from the publish output
file=$(find imagecatalog/bin -type f -iname '*.exe' -print | head -n1 || true)
if [ -z "$file" ]; then file=$(find imagecatalog -type f -iname '*.exe' -print | head -n1 || true); fi
if [ -z "$file" ]; then echo "No artifact EXE found to attach"; exit 1; fi
echo "Uploading artifact: $file"
uploadResp=$(curl --silent --show-error --header "JOB-TOKEN:$CI_JOB_TOKEN" --form "file=@$file" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads")
# Attach the complete distributable ZIP, including native OpenCV/CUDA dependencies.
file=$(find imagecatalog/bin -type f -name 'ImageCatalog-avalonia-win-x64.zip' -print | head -n1 || true)
if [ -z "$file" ]; then echo "No Windows distributable ZIP found to attach"; exit 1; fi
basename="ImageCatalog-avalonia-win-x64-${version}.zip"
echo "Uploading artifact: $file as $basename"
uploadResp=$(curl --silent --show-error --header "JOB-TOKEN:$CI_JOB_TOKEN" --form "file=@$file;filename=$basename" "$CI_API_V4_URL/projects/$CI_PROJECT_ID/uploads")
assetPath=$(echo "$uploadResp" | sed -n 's/.*"url":"\([^\"]*\)".*/\1/p')
if [ -z "$assetPath" ]; then echo "Upload failed: $uploadResp"; exit 1; fi
assetUrl="$CI_SERVER_URL$assetPath"
echo "Uploaded asset url: $assetUrl"
basename=$(basename "$file")
export RELEASE_ASSET_URL="$assetUrl"
export ASSET_BASENAME="$basename"
artifacts:

View file

@ -174,4 +174,59 @@
<Copy SourceFiles="@(LocalCudaInferenceLibraryForPublish)" DestinationFolder="$(PublishDir)" SkipUnchangedFiles="true" Condition="'@(LocalCudaInferenceLibraryForPublish)' != ''" />
</Target>
<Target Name="AssemblePackageCudaInferenceLibrariesToPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'win-x64' and '$(UseLocalAIFotoONLUS)' != 'true' and '$(PublishDir)' != ''">
<PropertyGroup>
<_CublasLtFragment0>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cuda11.cublaslt64_11.runtime.win-x64.f00/11.8.0/fragments/win-x64/native/cublasLt64_11.dll.f00'))</_CublasLtFragment0>
<_CublasLtFragment1>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cuda11.cublaslt64_11.runtime.win-x64.f01/11.8.0/fragments/win-x64/native/cublasLt64_11.dll.f01'))</_CublasLtFragment1>
<_CudnnCnnInferFragment0>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cudnn.cuda11.cudnn_cnn_infer64_8.runtime.win-x64.f00/8.9.7.29/fragments/win-x64/native/cudnn_cnn_infer64_8.dll.f00'))</_CudnnCnnInferFragment0>
<_CudnnCnnInferFragment1>$([System.IO.Path]::GetFullPath('$(NuGetPackageRoot)ntvlibs.cudnn.cuda11.cudnn_cnn_infer64_8.runtime.win-x64.f01/8.9.7.29/fragments/win-x64/native/cudnn_cnn_infer64_8.dll.f01'))</_CudnnCnnInferFragment1>
<_CublasLtOutput>$([System.IO.Path]::GetFullPath('$(PublishDir)/cublasLt64_11.dll'))</_CublasLtOutput>
<_CudnnCnnInferOutput>$([System.IO.Path]::GetFullPath('$(PublishDir)/cudnn_cnn_infer64_8.dll'))</_CudnnCnnInferOutput>
</PropertyGroup>
<Error Condition="!Exists('$(_CublasLtFragment0)')" Text="Missing CUDA runtime fragment: $(_CublasLtFragment0)" />
<Error Condition="!Exists('$(_CublasLtFragment1)')" Text="Missing CUDA runtime fragment: $(_CublasLtFragment1)" />
<Error Condition="!Exists('$(_CudnnCnnInferFragment0)')" Text="Missing cuDNN runtime fragment: $(_CudnnCnnInferFragment0)" />
<Error Condition="!Exists('$(_CudnnCnnInferFragment1)')" Text="Missing cuDNN runtime fragment: $(_CudnnCnnInferFragment1)" />
<Exec Condition="$([MSBuild]::IsOsPlatform('Windows'))" Command="powershell -NoProfile -ExecutionPolicy Bypass -Command &quot;$ErrorActionPreference='Stop'; function Join-Binary([string]$outFile, [string[]]$parts) { $stream = [System.IO.File]::Create($outFile); try { foreach ($part in $parts) { $input = [System.IO.File]::OpenRead($part); try { $input.CopyTo($stream) } finally { $input.Dispose() } } } finally { $stream.Dispose() } }; Join-Binary '$(_CublasLtOutput)' @('$(_CublasLtFragment0)', '$(_CublasLtFragment1)'); Join-Binary '$(_CudnnCnnInferOutput)' @('$(_CudnnCnnInferFragment0)', '$(_CudnnCnnInferFragment1)')&quot;" />
<Exec Condition="!$([MSBuild]::IsOsPlatform('Windows'))" Command="cat &quot;$(_CublasLtFragment0)&quot; &quot;$(_CublasLtFragment1)&quot; &gt; &quot;$(_CublasLtOutput)&quot; &amp;&amp; cat &quot;$(_CudnnCnnInferFragment0)&quot; &quot;$(_CudnnCnnInferFragment1)&quot; &gt; &quot;$(_CudnnCnnInferOutput)&quot;" />
</Target>
<Target Name="ValidateWindowsCatalogPublishOutput">
<Error Condition="'$(PublishDir)' == ''" Text="PublishDir must be set before validating the Windows Catalog output." />
<PropertyGroup>
<_CatalogPublishDirectory>$([System.IO.Path]::GetFullPath('$(PublishDir)'))</_CatalogPublishDirectory>
<_OpenCvSharpRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'OpenCvSharpExtern.dll'))</_OpenCvSharpRuntimePath>
<_CublasRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cublas64_11.dll'))</_CublasRuntimePath>
<_CublasLtRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cublasLt64_11.dll'))</_CublasLtRuntimePath>
<_CudaRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudart64_110.dll'))</_CudaRuntimePath>
<_CudnnRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn64_8.dll'))</_CudnnRuntimePath>
<_CudnnOpsRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_ops_infer64_8.dll'))</_CudnnOpsRuntimePath>
<_CudnnAdvRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_adv_infer64_8.dll'))</_CudnnAdvRuntimePath>
<_CudnnCnnRuntimePath>$([System.IO.Path]::Combine('$(_CatalogPublishDirectory)', 'cudnn_cnn_infer64_8.dll'))</_CudnnCnnRuntimePath>
</PropertyGroup>
<ItemGroup>
<_CatalogPublishedExecutable Include="$(_CatalogPublishDirectory)/*.exe" />
</ItemGroup>
<Error Condition="!Exists('$(_CatalogPublishDirectory)')" Text="Windows Catalog publish directory does not exist: $(_CatalogPublishDirectory)" />
<Error Condition="'@(_CatalogPublishedExecutable)' == ''" Text="No Windows Catalog executable was found in $(_CatalogPublishDirectory)." />
<Error Condition="!Exists('$(_OpenCvSharpRuntimePath)')" Text="Required OpenCV runtime library is missing: $(_OpenCvSharpRuntimePath)" />
<Error Condition="!Exists('$(_CublasRuntimePath)')" Text="Required CUDA runtime library is missing: $(_CublasRuntimePath)" />
<Error Condition="!Exists('$(_CublasLtRuntimePath)')" Text="Required CUDA runtime library is missing: $(_CublasLtRuntimePath)" />
<Error Condition="!Exists('$(_CudaRuntimePath)')" Text="Required CUDA runtime library is missing: $(_CudaRuntimePath)" />
<Error Condition="!Exists('$(_CudnnRuntimePath)')" Text="Required cuDNN runtime library is missing: $(_CudnnRuntimePath)" />
<Error Condition="!Exists('$(_CudnnOpsRuntimePath)')" Text="Required cuDNN runtime library is missing: $(_CudnnOpsRuntimePath)" />
<Error Condition="!Exists('$(_CudnnAdvRuntimePath)')" Text="Required cuDNN runtime library is missing: $(_CudnnAdvRuntimePath)" />
<Error Condition="!Exists('$(_CudnnCnnRuntimePath)')" Text="Required cuDNN runtime library is missing: $(_CudnnCnnRuntimePath)" />
</Target>
<Target Name="PackageWindowsCatalogOutput" DependsOnTargets="ValidateWindowsCatalogPublishOutput">
<Error Condition="'$(PublishArchivePath)' == ''" Text="PublishArchivePath must be set before packaging the Windows Catalog output." />
<PropertyGroup>
<_CatalogPublishArchivePath Condition="'$(PublishArchivePath)' != ''">$([System.IO.Path]::GetFullPath('$(PublishArchivePath)'))</_CatalogPublishArchivePath>
</PropertyGroup>
<ZipDirectory SourceDirectory="$(_CatalogPublishDirectory)" DestinationFile="$(_CatalogPublishArchivePath)" Overwrite="true" />
</Target>
</Project>