ci(windows): GitHub 云构建 Windows 安装器暂存 NAS + 发版可选来源(home/github)

家里 Windows runner 关机时的备用构建源。
- windows.yml: 构建 Inno 安装器(复用 compile-windows.sh)→ 暂存 NAS gitea winstage-v<版本>
- deploy-client.yml: build-windows 加 home/github 开关(参数 windows_source 优先,变量 WINDOWS_SOURCE 兜底),新增 build-windows-ci 从 NAS 按版本拉取
- stage/fetch 脚本: 版本强匹配,拉不到硬失败

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P9G7E3wmAYL9KeYCVZVsqu
This commit is contained in:
wangjia
2026-07-18 07:08:48 +08:00
parent fd654f21ac
commit 0a54ded445
4 changed files with 189 additions and 22 deletions
+49 -21
View File
@@ -1,19 +1,32 @@
name: Build Windows (jiu client)
name: Build & Stage Windows (jiu client)
# GitHub 云构建 Windows 桌面安装器(Inno),并暂存到 NAS gitea 的 winstage-v<版本>。
# 用途:家里那台 Windows runner 关机/连不上时的备用构建源。发版时把 gitea 仓库变量
# WINDOWS_SOURCE 设为 githubdeploy-client 就会按同版本从 NAS 拉这里暂存的安装器。
# 版本匹配:workflow_dispatch 填 ver(发版要 tag 的版本);push 触发则取 client/pubspec.yaml。
on:
workflow_dispatch:
inputs:
ver:
description: '版本号 (如 1.2.3;留空取 client/pubspec.yaml)。暂存到 winstage-v<版本>,发版按同版本拉取。'
required: false
default: ''
push:
branches: [ main ]
paths:
- 'client/**'
- '.github/workflows/windows.yml'
- 'scripts/ci/compile-windows.sh'
- 'deploy/windows/**'
jobs:
build-windows:
build-stage-windows:
runs-on: windows-latest
defaults:
run:
working-directory: client
env:
# 覆盖 _env.sh 的中国镜像默认值:GitHub runner 在美国,用国际源更快更稳。
PUB_HOSTED_URL: https://pub.dev
FLUTTER_STORAGE_BASE_URL: https://storage.googleapis.com
GOPROXY: https://proxy.golang.org,direct
steps:
- uses: actions/checkout@v4
@@ -21,25 +34,40 @@ jobs:
with:
channel: stable
- run: flutter --version
- run: flutter config --enable-windows-desktop
- run: flutter pub get
- run: flutter build windows --release --dart-define=BASE_URL=https://jiu.51yanmei.com --dart-define=PUBLIC_URL=https://jiu.51yanmei.com
- name: Package Release
- name: Install Inno Setup (idempotent)
shell: pwsh
run: |
$rel = Get-ChildItem -Path build/windows -Recurse -Directory -Filter Release |
Where-Object { $_.FullName -match 'runner' } | Select-Object -First 1
if (-not $rel) { throw 'Release dir not found' }
Write-Host "Release dir: $($rel.FullName)"
Compress-Archive -Path "$($rel.FullName)/*" -DestinationPath jiu-windows-x64.zip -Force
run: powershell -NoProfile -ExecutionPolicy Bypass -File scripts/ci/install-innosetup.ps1
- uses: actions/upload-artifact@v4
- name: Resolve version
id: ver
shell: bash
run: |
v="${{ inputs.ver }}"
if [ -z "$v" ]; then
v=$(grep -E '^version:' client/pubspec.yaml | head -1 | sed -E 's/^version:[[:space:]]*//; s/\+.*//')
fi
echo "ver=$v" >> "$GITHUB_OUTPUT"
echo "解析版本: $v"
# 复用与家里 runner 完全相同的构建脚本 → 产出 dist/jiu-windows-x64-setup.exe
# 保证云构建与家里构建出的安装器一致(BASE_URL/PUBLIC_URL=https://jiu.51yanmei.com)。
- name: Build Windows installer (Inno)
shell: bash
run: bash scripts/ci/compile-windows.sh "client-v${{ steps.ver.outputs.ver }}"
- name: Upload installer artifact (GitHub 备份,可直接下载)
uses: actions/upload-artifact@v4
with:
name: jiu-windows-x64
path: client/jiu-windows-x64.zip
name: jiu-windows-x64-setup
path: dist/jiu-windows-x64-setup.exe
if-no-files-found: error
- name: Stage installer → NAS gitea (winstage-v<版本>)
shell: bash
env:
FORGEJO_URL: ${{ secrets.FORGEJO_URL }}
FORGEJO_TOKEN: ${{ secrets.FORGEJO_TOKEN }}
GITEA_REPOSITORY: ${{ vars.GITEA_REPOSITORY || 'wangjia/jiu' }}
run: bash scripts/ci/stage-windows-forgejo.sh "client-v${{ steps.ver.outputs.ver }}"