版本号

This commit is contained in:
dzc committed 2026-09-23 18:45:57 +08:00
1 parent 6a9dbf9080
commit 7897e77c52
7 files changed
+95 -4

No files matched your search

+8 -1
View File
@@ -7,7 +7,14 @@ cd "$(dirname "$0")/.."
APP_NAME="资安信插件助手"
APP="build/macos/Build/Products/Release/${APP_NAME}.app"
DMG="dist/${APP_NAME}-macOS.dmg"
# 版本号 = 1.0.<MMdd.HHmm>.<git短哈希>,写入 build_info.g.dart 并用于 dmg 文件名
GIT_HASH=$(git rev-parse --short HEAD 2>/dev/null || echo nogit)
STAMP=$(date +%m%d.%H%M)
VERSION="1.0.${STAMP}.${GIT_HASH}"
printf '// 由打包脚本自动生成(tool/package_windows.ps1 / tool/package_macos.sh),勿手改。\n// 手动 flutter build 未跑脚本时保持上次打包的值;脚本打包会写入"版本+git提交+时间"。\nconst String kBuildVersion = '"'"'%s'"'"';\n' "$VERSION" > lib/build_info.g.dart
DMG="dist/${APP_NAME}-macOS-${VERSION}.dmg"
echo "==> 版本号:$VERSION"
echo "==> flutter build macos --release"
flutter build macos --release
+59
View File
@@ -0,0 +1,59 @@
# 资安信插件助手 Windows 一键打包脚本(版本号自动注入)
# 用法:在项目根目录执行 powershell -ExecutionPolicy Bypass -File tool\package_windows.ps1
# 产物:dist\资安信插件助手-windows-setup-<版本>.exe
# 版本格式:1.0.<MMdd.HHmm>.<git短哈希>,同时写入:
# - lib\build_info.g.dart(App 内/manifest/启动日志可见)
# - 安装包文件名(一眼区分新旧包)
param(
[string]$InnoPath = "$env:LOCALAPPDATA\Programs\Inno Setup 6\ISCC.exe"
)
$ErrorActionPreference = 'Stop'
Set-Location (Join-Path $PSScriptRoot '..')
# ---- 1. 计算版本 ----
$gitHash = (git rev-parse --short HEAD).Trim()
if (-not $gitHash) { $gitHash = 'nogit' }
$stamp = Get-Date -Format 'MMdd.HHmm'
$version = "1.0.$stamp.$gitHash"
# ---- 2. 写入版本文件(UTF-8 无 BOM,Dart 兼容) ----
$dartContent = @"
// 由打包脚本自动生成(tool/package_windows.ps1 / tool/package_macos.sh),勿手改。
// 手动 flutter build 未跑脚本时保持上次打包的值;脚本打包会写入"版本+git提交+时间"。
const String kBuildVersion = '$version';
"@
[System.IO.File]::WriteAllText(
(Join-Path (Get-Location) 'lib\build_info.g.dart'),
$dartContent,
(New-Object System.Text.UTF8Encoding($false))
)
Write-Host "==> 版本号:$version(git=$gitHash)"
# ---- 3. flutter 构建 ----
Write-Host '==> flutter build windows --release'
flutter build windows --release
if ($LASTEXITCODE -ne 0) { throw 'flutter build 失败' }
# ---- 4. 定位 ISCC ----
if (-not (Test-Path $InnoPath)) {
$candidates = @(
'C:\Program Files (x86)\Inno Setup 6\ISCC.exe',
'C:\Program Files\Inno Setup 6\ISCC.exe'
)
$InnoPath = $candidates | Where-Object { Test-Path $_ } | Select-Object -First 1
}
if (-not $InnoPath) { throw "未找到 Inno Setup(ISCC.exe)。请安装 Inno 6:https://jrsoftware.org/isdl.php" }
# ---- 5. Inno 编译(带版本号注入安装包文件名) ----
Write-Host "==> iscc /DAppVersionFull=$version"
& $InnoPath "/DAppVersionFull=$version" 'windows\installer.iss'
if ($LASTEXITCODE -ne 0) { throw 'iscc 编译失败' }
# ---- 6. 收尾提示 ----
$out = "dist\资安信插件助手-windows-setup-$version.exe"
Write-Host ''
Write-Host '==> 打包完成'
if (Test-Path $out) { Get-Item $out | Select-Object Name, Length, LastWriteTime | Format-List }
Write-Host '提醒:安装新版前,先退出右下角托盘里旧版"资安信插件助手"(否则 38200 被旧实例占用,浏览器仍连旧版)。'
Write-Host '验证:安装后浏览器打开 http://127.0.0.1:38200/manifest ,version 字段应为:' $version