Skip to content

Commit 577d666

Browse files
committed
ci(release): find the Windows DLL where CMake actually puts it
The first real tag push ran release.yml end to end for the first time and the windows-x64 leg failed at "Package libraries (Windows)" with "DLL not found", while darwin-arm64, linux-x64 and linux-arm64 all succeeded - so the release job never ran and v0.7.0 has no GitHub Release. zvec's CMake sets CMAKE_RUNTIME_OUTPUT_DIRECTORY to ${PROJECT_BINARY_DIR}/bin and CMAKE_ARCHIVE/LIBRARY_OUTPUT_DIRECTORY to .../lib (zvec/cmake/bazel.cmake), and a DLL is a RUNTIME artifact. The Windows build here uses Ninja, which is single-config, so there is no Release/ subdirectory at all and the library lands at zvec/build/bin/zvec_c_api.dll. The step searched lib/Release, lib and bin/Release - the one directory that matters was missing from the list. The Publish JAR workflow resolves the same library correctly, which is why the identical cache entry (zvec-build-windows-x64-host-8321c13...-v0.7.0) worked there and not here. Resolve it the way publish-jar.yml does: search bin, bin/Release, lib and lib/Release in that order and match *zvec_c_api*.dll rather than one exact name, so a suffixed build still resolves. The step is bash now instead of pwsh - Git Bash is on every Windows runner (the license guard below already depends on it), both workflows then share one idiom, and the script can be syntax-checked and dry-run locally. That also fixes the diagnostics: the runner sets ErrorActionPreference=stop, so the old `Write-Error "DLL not found"` terminated the step before the `Get-ChildItem` listing below it could run, and the failure reported nothing to work from. The miss path now emits an ::error:: annotation and prints up to 40 *.dll/*.lib paths under zvec/build. Verified locally with `bash -n` plus three synthetic trees: the Ninja layout (dll in bin/, lib in lib/) stages windows_amd64/zvec_c_api.{dll,lib} along with c_api.h, both jieba dict files, LICENSE and NOTICE; the multi-config layout (bin/Release, lib/Release) resolves too; and a tree without the DLL prints the annotation, lists what is present and exits 1. actionlint reports the same six pre-existing shellcheck infos as before.
1 parent b5a7fc8 commit 577d666

1 file changed

Lines changed: 48 additions & 45 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -260,61 +260,64 @@ jobs:
260260
261261
- name: Package libraries (Windows)
262262
if: runner.os == 'Windows'
263+
# bash rather than pwsh: the same library is resolved in bash by the
264+
# Publish JAR workflow's "Resolve zvec lib directory" step, and Git Bash
265+
# is present on every Windows runner (the license guard below already
266+
# relies on it). One idiom for both workflows, and a failure here prints
267+
# what is actually on disk - under pwsh the runner's
268+
# ErrorActionPreference=stop made Write-Error end the step before the
269+
# diagnostic listing could run, so the first failure said only
270+
# "DLL not found".
271+
shell: bash
263272
run: |
264-
$platform = "${{ matrix.platform }}"
265-
New-Item -ItemType Directory -Force -Path "staging/$platform" | Out-Null
266-
New-Item -ItemType Directory -Force -Path "staging/include/zvec" | Out-Null
267-
268-
# Find DLL (location varies by CMake generator)
269-
$dllCandidates = @(
270-
"zvec/build/lib/Release/zvec_c_api.dll",
271-
"zvec/build/lib/zvec_c_api.dll",
272-
"zvec/build/bin/Release/zvec_c_api.dll"
273-
)
274-
$found = $false
275-
foreach ($p in $dllCandidates) {
276-
if (Test-Path $p) {
277-
Copy-Item $p "staging/$platform/"
278-
Write-Host "✓ Copied DLL from $p"
279-
$found = $true; break
280-
}
281-
}
282-
if (-not $found) {
283-
Write-Error "DLL not found"
284-
Get-ChildItem -Recurse zvec/build/ -Filter *.dll
285-
exit 1
273+
PLATFORM="${{ matrix.platform }}"
274+
mkdir -p "staging/$PLATFORM" staging/include/zvec
275+
276+
# zvec's CMake sends RUNTIME output (.dll plus executables) to
277+
# build/bin and ARCHIVE/LIBRARY output (.lib, .so, .dylib) to
278+
# build/lib - see zvec/cmake/bazel.cmake - while a Release/
279+
# subdirectory only exists with a multi-config generator. This
280+
# workflow builds with Ninja, so the DLL is in build/bin; search every
281+
# layout anyway and match on a wildcard so a suffixed name resolves.
282+
find_c_api() {
283+
for d in zvec/build/bin zvec/build/bin/Release zvec/build/lib zvec/build/lib/Release; do
284+
[ -d "$d" ] || continue
285+
find "$d" -maxdepth 1 -type f -name "*zvec_c_api*$1" 2>/dev/null | head -n1
286+
done
286287
}
287288
288-
# Import library (.lib) – optional but useful for downstream C/C++ consumers
289-
$libCandidates = @(
290-
"zvec/build/lib/Release/zvec_c_api.lib",
291-
"zvec/build/lib/zvec_c_api.lib"
292-
)
293-
foreach ($p in $libCandidates) {
294-
if (Test-Path $p) {
295-
Copy-Item $p "staging/$platform/"
296-
Write-Host "✓ Copied import lib from $p"
297-
break
298-
}
299-
}
289+
DLL=$(find_c_api .dll | head -n1)
290+
if [ -z "$DLL" ]; then
291+
echo "::error::zvec_c_api DLL not found under zvec/build"
292+
find zvec/build \( -name '*.dll' -o -name '*.lib' \) -print 2>/dev/null | head -40
293+
exit 1
294+
fi
295+
cp "$DLL" "staging/$PLATFORM/"
296+
echo "✓ Copied DLL from $DLL"
297+
298+
# Import library (.lib) - optional but useful for downstream C/C++ consumers
299+
LIB=$(find_c_api .lib | head -n1)
300+
if [ -n "$LIB" ]; then
301+
cp "$LIB" "staging/$PLATFORM/"
302+
echo "✓ Copied import lib from $LIB"
303+
fi
300304
301305
# Public header
302-
Copy-Item "zvec/src/include/zvec/c_api.h" "staging/include/zvec/"
303-
Write-Host "✓ Copied c_api.h"
306+
cp zvec/src/include/zvec/c_api.h staging/include/zvec/
307+
echo "✓ Copied c_api.h"
304308
305309
# Jieba dict (mirrors the zvec SDK layout data/jieba_dict)
306-
New-Item -ItemType Directory -Force -Path "staging/data/jieba_dict" | Out-Null
307-
Copy-Item "zvec/thirdparty/cppjieba/cppjieba-5.6.7/dict/jieba.dict.utf8" "staging/data/jieba_dict/"
308-
Copy-Item "zvec/thirdparty/cppjieba/cppjieba-5.6.7/dict/hmm_model.utf8" "staging/data/jieba_dict/"
309-
Write-Host "✓ Copied jieba dict"
310+
mkdir -p staging/data/jieba_dict
311+
cp zvec/thirdparty/cppjieba/cppjieba-5.6.7/dict/jieba.dict.utf8 staging/data/jieba_dict/
312+
cp zvec/thirdparty/cppjieba/cppjieba-5.6.7/dict/hmm_model.utf8 staging/data/jieba_dict/
313+
echo "✓ Copied jieba dict"
310314
311315
# Apache-2.0 4(d): carry zvec's license and attribution notices.
312-
Copy-Item "zvec/LICENSE" "staging/LICENSE"
313-
Copy-Item "zvec/NOTICE" "staging/NOTICE"
314-
Write-Host "✓ Copied LICENSE + NOTICE"
316+
cp zvec/LICENSE staging/LICENSE
317+
cp zvec/NOTICE staging/NOTICE
318+
echo "✓ Copied LICENSE + NOTICE"
315319
316-
Get-ChildItem "staging/$platform/"
317-
shell: pwsh
320+
ls -la "staging/$PLATFORM/"
318321
319322
# --- License guard ---
320323
# The archives attached to the GitHub Release carry the same zvec_c_api

0 commit comments

Comments
 (0)