From 3aa63d65753b386bb4c480b3894becae3377db91 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Wed, 3 Jun 2026 00:23:09 +0800 Subject: [PATCH] =?UTF-8?q?fix(ci):=20Windows=20=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E6=94=B9=E7=94=A8=20C:\jiu-build=20=E7=9F=AD=E8=B7=AF=E5=BE=84?= =?UTF-8?q?=EF=BC=8C=E5=BC=83=E7=94=A8=20subst=20W:=20=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit subst W: 因 cmd/MSYS 引号转义失败(报"找不到路径"),导致 W: 盘 未创建、cd /w/client 失败。改为将 client/ 复制到 System32 之外的 C:\jiu-build 构建,规避 WOW64 重定向,并用 PowerShell Compress-Archive 打包。 Co-Authored-By: Claude Opus 4.8 --- CHANGELOG.md | 5 ++++ scripts/ci/compile-windows.sh | 50 ++++++++++++++++------------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad97c2..852ad52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.0.5] - 2026-06-03 + +### 修复 +- 修复 Windows CI 构建失败:放弃脆弱的 `subst W:` 路径映射,改为将 client/ 复制到 System32 之外的干净短路径(C:\jiu-build)构建,规避 WOW64 文件系统重定向 + ## [1.0.4] - 2026-05-30 ### 新功能 diff --git a/scripts/ci/compile-windows.sh b/scripts/ci/compile-windows.sh index ba24859..d1b4768 100755 --- a/scripts/ci/compile-windows.sh +++ b/scripts/ci/compile-windows.sh @@ -11,43 +11,39 @@ VER="${TAG#v}" echo "==> compile-windows: version=${VER}" -# Sync Flutter pubspec version +# Sync Flutter pubspec version (done in the checkout, before copying out) sed -i "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml -# Build Flutter Windows -# Use subst to create a short path (W:) to avoid WOW64 redirection issue -# when workspace is under C:\Windows\System32\config\systemprofile -WORKSPACE_WIN=$(cygpath -w "$(pwd)") -echo "==> workspace: $WORKSPACE_WIN" -cmd //c "subst W: \"${WORKSPACE_WIN}\"" || true +# The Forgejo Windows runner checks out under +# C:\Windows\System32\config\systemprofile\.cache\act\...\hostexecutor +# Building there triggers WOW64 filesystem redirection (System32 -> SysWOW64) +# which breaks CMake/Flutter native paths. So copy the Flutter project to a +# clean short path OUTSIDE System32 and build there. This replaces the previous +# `subst W:` trick, which was fragile due to cmd/MSYS quoting. +BUILD_ROOT="/c/jiu-build" +BUILD_CLIENT="${BUILD_ROOT}/client" -cd /w/client +echo "==> copying client/ to ${BUILD_CLIENT}" +rm -rf "$BUILD_ROOT" +mkdir -p "$BUILD_ROOT" +cp -r client "$BUILD_CLIENT" + +# Build (run from the clean path; pushd/popd avoids needing $() to save cwd) +pushd "$BUILD_CLIENT" > /dev/null flutter create --platforms=windows . --project-name jiu_client flutter build windows --release \ "--dart-define=BASE_URL=https://jiu.51yanmei.com" \ "--dart-define=PUBLIC_URL=https://jiu.51yanmei.com" \ "--dart-define=APP_VERSION=${TAG}" -cd /w +popd > /dev/null -cmd //c "subst W: /d" || true - -# Package release folder into zip using Python (available on all platforms) +# Package the Release folder into dist/ using PowerShell Compress-Archive. +# Source is an absolute Windows path; destination is relative to the workspace. mkdir -p dist -python3 - <<'PYEOF' -import zipfile, os - -src = os.path.join('W:\\', 'client', 'build', 'windows', 'x64', 'runner', 'Release') if os.path.exists('W:\\') else os.path.join('client', 'build', 'windows', 'x64', 'runner', 'Release') -dst = os.path.join('dist', 'jiu-windows-x64.zip') - -with zipfile.ZipFile(dst, 'w', zipfile.ZIP_DEFLATED) as zf: - for root, dirs, files in os.walk(src): - for fname in files: - fp = os.path.join(root, fname) - zf.write(fp, os.path.relpath(fp, src)) - -size = os.path.getsize(dst) -print(f'Packaged {dst} ({size // 1024 // 1024} MB)') -PYEOF +REL_WIN='C:\jiu-build\client\build\windows\x64\runner\Release' +echo "==> packaging ${REL_WIN} -> dist/jiu-windows-x64.zip" +powershell -NoProfile -Command \ + "Compress-Archive -Path '${REL_WIN}\*' -DestinationPath 'dist\jiu-windows-x64.zip' -Force" echo "==> compile-windows: done — dist/ contents:" ls -lh dist/