Files
EasyDesignCollection/scripts/publish_release.ps1
T
admin fe5e0be131 feat(flow): 泳道拓宽计划(空泳道策略 + 多槽位泳道,三视图同步);发布 v1.3.4
- 空泳道策略(F2 文档设置 →「泳道」):动作全部移走的泳道可保留(默认,序号不变)
  或自动移除;条形空行 / 圆周空环 / 流程空列与左侧栏占位行同步
- 泳道加宽(1–5 槽):双击条形视图左侧泳道编号 / 右键空白泳道 / 左侧栏「N 槽」徽标;
  条形分子行(浅色虚线分隔)、圆周同色加宽环带 + 槽位虚线、流程图分子列且泳道带
  随内容智能加宽;拖拽动作同时换道 + 换槽位;旧数据零迁移(row 语义改为槽位并自动钳制)
- 流程图智能排开:同源同层扇出连线在空隙内均匀铺开;同层节点水平重叠自动推开
- 显示修复:画布左栏标题按真实行高排版(灰色副标题不再被换行标题压住,
  持续换行到泳道高度不足);多槽位采用「槽位紧凑 + 泳道间拉开」的间隔
- 「时序创建和编辑」更名为「文档设置」(含对话框标题/帮助/文档);新增自动保存
  (默认 10 分钟,可选 1/5/10/30 或关闭;写入文件并同步 .bak)
- 授权临时冻结(kLicenseRequired=false):桌面版导出无需 .lic;关于页授权状态
  「开放授权版本」、EDC 版权、开发者与交流群(邮箱 liuyu65@126.com、微信 online-goose)
- 更新体验:直接升级到最新版本提示、下载过程保持屏幕常亮提示、
  下载/上传统一限速 320KB/s(客户端限速 + 发布脚本 --limit-rate 320k)
- docs/HELP.md 与帮助中心同步更新;新增 docs/ROADMAP.md 开发路线图
- flutter analyze 0 问题、40 项测试全过;演示截图更新(含泳道加宽与拥挤场景验证图)
2026-10-10 09:21:45 +08:00

151 lines
7.1 KiB
PowerShell
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# ============================================================
# 发布新版本到 Gitea Releases(更新说明 + 安装包附件)
#
# 用法(在仓库根目录或任意位置):
# powershell -File scripts\publish_release.ps1 -Version 1.2.1 `
# -NotesFile release\RELEASE_NOTES_v1.2.1.md
#
# 说明:
# - 更新说明写入 Release 正文(Markdown),客户端「检查更新」时读取展示;
# - 安卓 APK:默认取 release\sequence_diagram_android_v<版本>_release.apk;
# - Windows 绿色版:默认把 dist\ 打包为 zip 后上传(客户端下载后原地覆盖);
# - 安装包作为 Release 附件保存,不进入 git 历史,仓库保持精简;
# - 发布幂等:v<版本> 已存在(如上次上传中断)时复用它并更新说明;
# - 发布完成后自动清理历史附件:只保留「最新 1 个版本」的安装包
# (Release 记录与更新说明保留,仅删除更早版本的附件,释放服务器空间)。
# ============================================================
param(
[Parameter(Mandatory = $true)][string]$Version,
[Parameter(Mandatory = $true)][string]$NotesFile,
[string]$ApkPath = "",
[string]$WindowsZipPath = "",
[string]$Server = "http://124.220.63.9:30000",
[string]$Owner = "admin",
[string]$Repo = "Sequence-Diagram",
[string]$Auth = "liuyu65@126.com:ds3317210",
# 上传限速(curl --limit-rate):服务器带宽很小(5Mbps),
# 限速上传避免打满带宽把服务器压垮(默认 320KB/s ≈ 2.6Mbps)。
[string]$UploadLimit = "320k"
)
$ErrorActionPreference = "Stop"
$root = Split-Path -Parent $PSScriptRoot # 仓库根目录(scripts 的上一级)
# ---- 1) 定位安装包 ----
if ($ApkPath -eq "") {
$ApkPath = Join-Path $root "release\sequence_diagram_android_v${Version}_release.apk"
}
if (!(Test-Path $ApkPath)) {
throw "找不到 APK:$ApkPath(先执行 flutter build apk --release 并归档到 release\)"
}
if ($WindowsZipPath -eq "") {
$WindowsZipPath = Join-Path $env:TEMP "sequence_diagram_windows_v${Version}.zip"
}
if (!(Test-Path $WindowsZipPath) -or (Get-Item $WindowsZipPath).Length -lt 1048576) {
$dist = Join-Path $root "dist"
if (!(Test-Path (Join-Path $dist "sequence_diagram.exe"))) {
throw "找不到 dist\sequence_diagram.exe(先执行 flutter build windows --release 并同步到 dist\)"
}
Write-Host "打包 Windows 绿色版:$WindowsZipPath"
if (Test-Path $WindowsZipPath) { Remove-Item $WindowsZipPath -Force }
& tar.exe -a -cf $WindowsZipPath -C $dist .
if ($LASTEXITCODE -ne 0) { throw "打包失败" }
}
if (!(Test-Path $NotesFile)) { throw "找不到更新说明文件:$NotesFile" }
$notes = [System.IO.File]::ReadAllText($NotesFile, [System.Text.Encoding]::UTF8)
# ---- 2) 创建(或复用)Release(正文 = 更新说明) ----
# 幂等:若 v<版本> 已存在(如上次发布上传中断),复用该 Release 并更新说明。
$tmp = Join-Path $env:TEMP "seq_release.json"
$tagFile = Join-Path $env:TEMP "seq_release_tag.json"
curl.exe -s --max-time 300 -o $tagFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
$rel = $null
try {
$rel = [System.IO.File]::ReadAllText($tagFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
} catch {
$rel = $null
}
if ($rel -and $rel.id) {
Write-Host "Release v$Version 已存在(id=$($rel.id)),复用并更新说明..."
$payload = @{ body = $notes } | ConvertTo-Json -Compress
[System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false)))
curl.exe -s --max-time 300 -o NUL -X PATCH -H "Content-Type: application/json" --data-binary "@$tmp" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)" | Out-Null
} else {
$payload = @{
tag_name = "v$Version"
name = "v$Version"
body = $notes
draft = $false
prerelease = $false
} | ConvertTo-Json -Compress
[System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false)))
Write-Host "创建 Release v$Version ..."
$resp = curl.exe -s --max-time 300 -X POST -H "Content-Type: application/json" --data-binary "@$tmp" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases"
$rel = $resp | ConvertFrom-Json
if (-not $rel.id) { throw "创建 Release 失败:$resp" }
}
Write-Host "Release id = $($rel.id)"
# ---- 3) 上传附件 ----
# 同名附件先删后传:支持上传中断后重跑(避免重名重复)。
# 注意:大文件上传不设 --max-time(慢链路下需要数分钟)。
function Upload-Asset([string]$path) {
$name = Split-Path $path -Leaf
$curFile = Join-Path $env:TEMP "seq_release_cur.json"
curl.exe -s --max-time 300 -o $curFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
try {
$cur = [System.IO.File]::ReadAllText($curFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
foreach ($a in $cur.assets) {
if ($a.name -eq $name) {
curl.exe -s --max-time 300 -o NUL -X DELETE -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets/$($a.id)" | Out-Null
}
}
} catch {}
Write-Host "上传附件:$name (限速 $UploadLimit)..."
$r = curl.exe -s --limit-rate $UploadLimit -X POST -F "attachment=@$path" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets?name=$name"
$asset = $r | ConvertFrom-Json
if (-not $asset.name) { throw "上传失败:$r" }
Write-Host " 完成:$($asset.browser_download_url)"
}
Upload-Asset $ApkPath
Upload-Asset $WindowsZipPath
# ---- 4) 清理历史版本附件:只保留最新 1 个版本的安装包 ----
# 客户端更新只使用「最新版本」的附件,更早版本的安装包可安全删除以释放空间;
# Release 记录与更新说明保留,历史版本页面仍可查阅。
# 该步骤失败不影响本次发布(仅打印警告)。
$keepVersions = 1
try {
Write-Host ""
Write-Host "清理历史版本附件(只保留最新 $keepVersions 个版本)..."
$listFile = Join-Path $env:TEMP "seq_releases_list.json"
curl.exe -s --max-time 300 -o $listFile "$Server/api/v1/repos/$Owner/$Repo/releases?limit=50" | Out-Null
$all = [System.IO.File]::ReadAllText($listFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
$ordered = @($all | Sort-Object -Property created_at -Descending)
$freed = 0
for ($i = $keepVersions; $i -lt $ordered.Count; $i++) {
$r = $ordered[$i]
foreach ($a in $r.assets) {
$code = curl.exe -s --max-time 300 -o NUL -w "%{http_code}" -X DELETE -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($r.id)/assets/$($a.id)"
if ($code -eq "204") {
$freed += $a.size
Write-Host " 已清理 $($r.tag_name) / $($a.name)"
} else {
Write-Host " [warn] 清理失败 $($r.tag_name) / $($a.name):HTTP $code"
}
}
}
if ($freed -gt 0) {
Write-Host " 共释放 $([math]::Round($freed / 1MB, 1)) MB"
} else {
Write-Host " 无需清理(仅最新 $keepVersions 个版本带有附件)"
}
} catch {
Write-Host " [warn] 历史附件清理失败(不影响本次发布):$_"
}
Write-Host ""
Write-Host "发布完成!客户端下次启动即可检查到 v$Version($Server/$Owner/$Repo/releases)"