feat(deploy): 新增 Windows 桌面客户端构建与发布支持
CI 拆成三个 job(mac 构建 Linux/Web、windows 构建 Windows 桌面、mac 发布部署);新增 compile-windows.sh 用 Flutter 构建并打包为 jiu-windows-x64.zip;release.sh 自动写入 Windows 下载 URL 到 version.yaml 并上传 zip。下载页 Windows 卡片从"敬请期待"改为真实下载按钮,URL 由 API 动态填充。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
sed -i "s/^version:.*/version: ${VER}+1/" client/pubspec.yaml
|
||||
|
||||
# Build Flutter Windows
|
||||
cd 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 ..
|
||||
|
||||
# Package release folder into zip using Python (available on all platforms)
|
||||
mkdir -p dist
|
||||
python3 - <<'PYEOF'
|
||||
import zipfile, os
|
||||
|
||||
src = 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
|
||||
|
||||
echo "==> compile-windows: done — dist/ contents:"
|
||||
ls -lh dist/
|
||||
+12
-4
@@ -36,11 +36,16 @@ PYEOF
|
||||
|
||||
echo "==> release: release_notes=${RELEASE_NOTES}"
|
||||
|
||||
# Update backend/config/version.yaml
|
||||
python3 - "${VER}" "${RELEASE_NOTES}" <<'PYEOF'
|
||||
# Update backend/config/version.yaml (version, build_number, release_notes, windows URL)
|
||||
python3 - "${VER}" "${RELEASE_NOTES}" "${TAG}" "${FORGEJO_URL}" "${GITEA_REPOSITORY}" <<'PYEOF'
|
||||
import sys
|
||||
ver = sys.argv[1]
|
||||
ver = sys.argv[1]
|
||||
notes = sys.argv[2]
|
||||
tag = sys.argv[3]
|
||||
furl = sys.argv[4].rstrip('/')
|
||||
repo = sys.argv[5]
|
||||
win_url = f"{furl}/{repo}/releases/download/{tag}/jiu-windows-x64.zip"
|
||||
|
||||
lines = []
|
||||
with open('backend/config/version.yaml') as f:
|
||||
for line in f:
|
||||
@@ -54,11 +59,13 @@ with open('backend/config/version.yaml') as f:
|
||||
lines.append('build_number: ' + str(build) + '\n')
|
||||
elif line.startswith('release_notes:'):
|
||||
lines.append('release_notes: "' + notes.replace('\\', '\\\\').replace('"', '\\"') + '"\n')
|
||||
elif line.startswith(' windows:'):
|
||||
lines.append(' windows: "' + win_url + '"\n')
|
||||
else:
|
||||
lines.append(line)
|
||||
with open('backend/config/version.yaml', 'w') as f:
|
||||
f.writelines(lines)
|
||||
print('version.yaml updated to', ver)
|
||||
print('version.yaml updated to', ver, '| windows:', win_url)
|
||||
PYEOF
|
||||
|
||||
# Package configs.tar.gz (includes updated version.yaml)
|
||||
@@ -115,5 +122,6 @@ upload_asset() {
|
||||
upload_asset dist/jiu-server
|
||||
upload_asset dist/web.tar.gz
|
||||
upload_asset dist/configs.tar.gz
|
||||
upload_asset dist/jiu-windows-x64.zip
|
||||
|
||||
echo "==> release: done — Release ${TAG} created"
|
||||
|
||||
Reference in New Issue
Block a user