chore: keep build tooling in workflow only
Some checks failed
Build Windows Release / build-windows (push) Has been cancelled
Some checks failed
Build Windows Release / build-windows (push) Has been cancelled
This commit is contained in:
@@ -14,30 +14,94 @@ on:
|
||||
jobs:
|
||||
build-windows:
|
||||
runs-on: windows-latest
|
||||
defaults:
|
||||
run:
|
||||
shell: msys2 {0}
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Configure MSVC environment
|
||||
uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: Setup MSYS2 build environment
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
arch: x64
|
||||
msystem: UCRT64
|
||||
update: true
|
||||
install: >-
|
||||
git
|
||||
zip
|
||||
p7zip
|
||||
mingw-w64-ucrt-x86_64-toolchain
|
||||
mingw-w64-ucrt-x86_64-cmake
|
||||
mingw-w64-ucrt-x86_64-ninja
|
||||
mingw-w64-ucrt-x86_64-qt6-base
|
||||
mingw-w64-ucrt-x86_64-opencv
|
||||
|
||||
- name: Build and package Windows app
|
||||
shell: pwsh
|
||||
- name: Configure
|
||||
run: |
|
||||
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process -Force
|
||||
.\scripts\package-windows-release.ps1 -Toolchain msvc
|
||||
cmake -S . -B build-windows -G Ninja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCMAKE_PREFIX_PATH=/ucrt64
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
cmake --build build-windows --parallel "$(nproc)"
|
||||
|
||||
- name: Package
|
||||
run: |
|
||||
set -euo pipefail
|
||||
APP_NAME="chengnan"
|
||||
PACKAGE_NAME="chengnan-windows-x86_64"
|
||||
PACKAGE_DIR="dist-windows/${PACKAGE_NAME}"
|
||||
EXE="build-windows/${APP_NAME}.exe"
|
||||
|
||||
test -f "$EXE"
|
||||
rm -rf dist-windows
|
||||
mkdir -p "$PACKAGE_DIR"
|
||||
cp "$EXE" "$PACKAGE_DIR/"
|
||||
|
||||
# 部署 Qt 运行时和插件。
|
||||
if command -v windeployqt >/dev/null 2>&1; then
|
||||
windeployqt --release --no-translations "$PACKAGE_DIR/${APP_NAME}.exe"
|
||||
elif command -v windeployqt6 >/dev/null 2>&1; then
|
||||
windeployqt6 --release --no-translations "$PACKAGE_DIR/${APP_NAME}.exe"
|
||||
else
|
||||
echo "windeployqt not found" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 收集 MinGW/MSYS2/OpenCV 运行时 DLL。ldd 会列出 exe/dll 依赖;循环几轮收集二级依赖。
|
||||
for round in 1 2 3; do
|
||||
while IFS= read -r binary; do
|
||||
while IFS= read -r dll; do
|
||||
[ -f "$dll" ] || continue
|
||||
cp -n "$dll" "$PACKAGE_DIR/" || true
|
||||
done < <(ldd "$binary" \
|
||||
| awk '/=> \/ucrt64\/bin\// {print $3} /^\/ucrt64\/bin\// {print $1}' \
|
||||
| sort -u)
|
||||
done < <(find "$PACKAGE_DIR" -maxdepth 2 -type f \( -name '*.exe' -o -name '*.dll' \) | sort)
|
||||
done
|
||||
|
||||
cat > "$PACKAGE_DIR/README.txt" <<'EOF'
|
||||
chengnan Windows x86_64 发布包
|
||||
|
||||
运行方式:
|
||||
1. 解压整个目录。
|
||||
2. 双击 chengnan.exe 运行。
|
||||
|
||||
说明:
|
||||
- 本目录已包含 Qt、OpenCV 和 MinGW 运行时 DLL。
|
||||
- 请不要只复制 chengnan.exe,需保留同目录 DLL 和 Qt plugins 子目录。
|
||||
EOF
|
||||
|
||||
(cd dist-windows && 7z a -tzip "${PACKAGE_NAME}.zip" "${PACKAGE_NAME}" >/dev/null)
|
||||
(cd dist-windows && sha256sum "${PACKAGE_NAME}.zip" > "${PACKAGE_NAME}.zip.sha256")
|
||||
|
||||
- name: Verify package
|
||||
shell: pwsh
|
||||
run: |
|
||||
if (!(Test-Path .\dist-windows\chengnan-windows-x86_64.zip)) { throw "missing zip" }
|
||||
if (!(Test-Path .\dist-windows\chengnan-windows-x86_64.zip.sha256)) { throw "missing sha256" }
|
||||
$zip = Get-Item .\dist-windows\chengnan-windows-x86_64.zip
|
||||
if ($zip.Length -le 0) { throw "empty zip" }
|
||||
$hashLine = Get-Content .\dist-windows\chengnan-windows-x86_64.zip.sha256
|
||||
if ($hashLine -notmatch '^[0-9a-f]{64}\s+chengnan-windows-x86_64\.zip$') { throw "invalid sha256 file" }
|
||||
test -s dist-windows/chengnan-windows-x86_64.zip
|
||||
sha256sum -c dist-windows/chengnan-windows-x86_64.zip.sha256
|
||||
7z l dist-windows/chengnan-windows-x86_64.zip | grep 'chengnan.exe'
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
|
||||
Reference in New Issue
Block a user