Files
jiu/scripts/ci/compile-windows.sh
T
wangjia 3aa63d6575
Deploy / build-windows (push) Successful in 1m41s
Deploy / build-linux-web (push) Failing after 14m36s
Deploy / build-macos (push) Successful in 33m24s
Deploy / release-deploy (push) Has been skipped
fix(ci): Windows 构建改用 C:\jiu-build 短路径,弃用 subst W: 映射
subst W: 因 cmd/MSYS 引号转义失败(报"找不到路径"),导致 W: 盘
未创建、cd /w/client 失败。改为将 client/ 复制到 System32 之外的
C:\jiu-build 构建,规避 WOW64 重定向,并用 PowerShell Compress-Archive 打包。

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-03 00:23:09 +08:00

50 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# compile-windows.sh <tag> — build Flutter Windows desktop, package into dist/
set -euo pipefail
export GOPROXY="${GOPROXY:-https://goproxy.cn,direct}"
export PUB_HOSTED_URL="${PUB_HOSTED_URL:-https://pub.flutter-io.cn}"
export FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-https://storage.flutter-io.cn}"
TAG="$1"
VER="${TAG#v}"
echo "==> compile-windows: version=${VER}"
# Sync Flutter pubspec version (done in the checkout, before copying out)
sed -i "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml
# 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"
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}"
popd > /dev/null
# 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
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/