mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-07 05:42:43 +08:00
* 🎨 style(DataGrid): 清理冗余代码与静态分析告警 - 类型重构:通过修正 React Context 的函数签名解决了 void 类型的链式调用错误 - 代码精简:利用 Nullish Coalescing (??) 优化组件配置项降级逻辑,剥离无意义的隐式 undefined 赋值 - 工具链适配:适配 IDE 拼写检查与 Promise strict rules,确保全文件零警 * 🔧 fix(db/kingbase_impl): 修复标识符无条件加双引号导致SQL语法报错 - quoteKingbaseIdent 改为条件引用,仅对大写字母、保留字、特殊字符的标识符添加双引号 - 新增 kingbaseIdentNeedsQuote 判断标识符是否需要引用 - 新增 isKingbaseReservedWord 检测常见SQL保留字 - 补充 TestQuoteKingbaseIdent、TestKingbaseIdentNeedsQuote 单测覆盖各场景 - refs #176 * 🔧 fix(release,db/kingbase_impl): 修复金仓默认 schema 并静默生成 DMG - Kingbase:在 current_schema() 为 public 时探测候选 schema,并通过 DSN search_path 重连,兼容未限定 schema 的查询 - 候选优先级:数据库名/用户名同名 schema(存在性校验),否则仅在“唯一用户 schema 有表”场景兜底 - 避免连接污染:每次 Connect 重置探测结果,重连成功后替换连接并关闭旧连接 - 打包脚本:create-dmg 增加 --sandbox-safe,避免构建时自动弹出/打开挂载窗口 - 产物格式:强制 --format UDZO,并将 rw.*.dmg/UDRW 中间产物转换为可分发 DMG - 校验门禁:增加 hdiutil verify,失败时保留 .app 便于排查,同时修正卷图标探测并补 ad-hoc 签名 * 🐛 fix(connection/redis): 修复 Redis URI 用户名处理导致认证失败 - Redis URI 解析回填 user 字段,兼容 redis://user:pass@... 与 redis://:pass@... - 生成 URI 时按需输出 user/password,避免丢失用户名信息 - Redis 类型默认用户名置空,并在构建配置时清理历史默认 root - 避免 go-redis 触发 ACL AUTH(user, pass) 导致 WRONGPASS - refs #212 * 🔧 fix(release,ssh): 修复 SSH 误判连接成功并纠正 DMG 打包结构 - SSH 缓存 key 纳入认证指纹(password/keyPath),避免改错凭证仍复用旧连接/端口转发 - MySQL/MariaDB/Doris:SSH 隧道建立失败直接返回错误,不再回退直连导致测试误判成功 - 新增最小单测覆盖 SSH cache key 与 UseSSH 异常路径 - build-release.sh:create-dmg 使用 staging 目录作为 source,避免 DMG 根目录变成 Contents - refs #213 * fix: KingBase 连接后自动设置 search_path,修复自定义 schema 下表查询报 relation does not exist 的问题 (#215) * 🔧 fix(driver/kingbase,mongodb): 修复外置驱动事务引用与连接测试链路问题 - 金仓外置驱动链路增加表名与变更字段归一化,修复 ApplyChanges 场景下双引号转义异常导致的 SQL 语法错误 - 新增金仓公共标识符工具并复用到 kingbase_impl 与 optional_driver_agent_impl,统一处理多重转义、schema.table 拆分与引用规范 - 金仓代理连接后自动探测并设置 search_path,降低查询时必须手写 schema 前缀的概率 - MongoDB 连接参数改为显式 host/hosts 优先,避免被 URI 中 localhost 覆盖;代理链路保留目标地址不再改写为本地地址 - 连接测试增加前后端超时收敛与日志增强,避免长时间转圈;连接错误文案在未启用 TLS 时移除误导性的“SSL”前缀 - 统一日志级别为 INFO/WARN/ERROR,默认日志目录收敛到 ~/.GoNavi/Logs,并补充驱动构建脚本 build-driver-agents.sh * 🔧 fix(release/sidebar): 统一跨平台UPX压缩并修复PG函数列表查询兼容性 - 构建脚本新增通用 UPX 压缩函数,覆盖 macOS、Linux、Windows 产物 - 本地打包改为强制压缩策略:未安装 upx、压缩失败或校验失败直接终止 - macOS 打包在签名前压缩 .app 主程序并执行 upx -t 校验 - Linux 打包在生成 tar.gz 前压缩可执行文件并执行 upx -t 校验 - GitHub Release 与测试构建流程补齐 macOS/Linux/Windows 的 upx 安装与压缩步骤 - PostgreSQL/PG-like 函数元数据查询增加多路兼容 SQL,修复函数列表不显示问题 - refs #221 - refs #222 --------- Co-authored-by: Syngnat <yangguofeng919@gmail.com> Co-authored-by: 凌封 <49424247+fengin@users.noreply.github.com>
617 lines
23 KiB
YAML
617 lines
23 KiB
YAML
name: Release
|
||
|
||
on:
|
||
push:
|
||
tags:
|
||
- 'v*'
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
jobs:
|
||
# Phase 1: Build in parallel and output artifacts
|
||
build:
|
||
name: Build ${{ matrix.platform }}
|
||
runs-on: ${{ matrix.os }}
|
||
strategy:
|
||
fail-fast: false
|
||
matrix:
|
||
include:
|
||
- os: macos-latest
|
||
platform: darwin/amd64
|
||
os_name: MacOS
|
||
arch_name: Amd64
|
||
build_name: gonavi-build-darwin-amd64
|
||
wails_tags: ""
|
||
artifact_suffix: ""
|
||
build_optional_agents: true
|
||
linux_webkit: ""
|
||
- os: macos-latest
|
||
platform: darwin/arm64
|
||
os_name: MacOS
|
||
arch_name: Arm64
|
||
build_name: gonavi-build-darwin-arm64
|
||
wails_tags: ""
|
||
artifact_suffix: ""
|
||
build_optional_agents: true
|
||
linux_webkit: ""
|
||
- os: windows-latest
|
||
platform: windows/amd64
|
||
os_name: Windows
|
||
arch_name: Amd64
|
||
build_name: gonavi-build-windows-amd64
|
||
wails_tags: ""
|
||
artifact_suffix: ""
|
||
build_optional_agents: true
|
||
linux_webkit: ""
|
||
- os: windows-latest
|
||
platform: windows/arm64
|
||
os_name: Windows
|
||
arch_name: Arm64
|
||
build_name: gonavi-build-windows-arm64
|
||
wails_tags: ""
|
||
artifact_suffix: ""
|
||
build_optional_agents: true
|
||
linux_webkit: ""
|
||
- os: ubuntu-22.04
|
||
platform: linux/amd64
|
||
os_name: Linux
|
||
arch_name: Amd64
|
||
build_name: gonavi-build-linux-amd64
|
||
wails_tags: ""
|
||
artifact_suffix: ""
|
||
build_optional_agents: true
|
||
linux_webkit: "4.0"
|
||
# Debian 13 (trixie) 默认仓库已切到 WebKitGTK 4.1:单独提供 4.1 变体产物
|
||
- os: ubuntu-24.04
|
||
platform: linux/amd64
|
||
os_name: Linux
|
||
arch_name: Amd64
|
||
build_name: gonavi-build-linux-amd64-webkit41
|
||
wails_tags: "webkit2_41"
|
||
artifact_suffix: "-WebKit41"
|
||
build_optional_agents: false
|
||
linux_webkit: "4.1"
|
||
|
||
steps:
|
||
- name: Checkout code
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Setup Go
|
||
uses: actions/setup-go@v5
|
||
with:
|
||
go-version: '1.24'
|
||
check-latest: true
|
||
|
||
- name: Setup Node
|
||
uses: actions/setup-node@v4
|
||
with:
|
||
node-version: '20'
|
||
|
||
- name: Install UPX (macOS)
|
||
if: contains(matrix.platform, 'darwin')
|
||
run: |
|
||
brew install upx
|
||
upx --version
|
||
|
||
- name: Install UPX (Windows)
|
||
if: contains(matrix.platform, 'windows')
|
||
shell: pwsh
|
||
run: |
|
||
choco install upx --no-progress -y
|
||
$upxCmd = Get-Command upx -ErrorAction SilentlyContinue
|
||
if ($null -eq $upxCmd) {
|
||
Write-Error "❌ 未检测到 upx,无法保证 Windows 产物经过压缩"
|
||
exit 1
|
||
}
|
||
& upx --version
|
||
|
||
# Linux Dependencies (GTK3, WebKit2GTK required by Wails)
|
||
- name: Install Linux Dependencies
|
||
if: contains(matrix.platform, 'linux')
|
||
run: |
|
||
sudo apt-get update
|
||
sudo apt-get install -y libgtk-3-dev
|
||
|
||
# WebKitGTK 4.1 需要 libsoup3;4.0 使用 libsoup2(通常由 webkit2gtk dev 包拉起)
|
||
if [ "${{ matrix.linux_webkit }}" = "4.1" ]; then
|
||
sudo apt-get install -y libwebkit2gtk-4.1-dev libsoup-3.0-dev
|
||
else
|
||
sudo apt-get install -y libwebkit2gtk-4.0-dev
|
||
fi
|
||
|
||
sudo apt-get install -y upx-ucl || sudo apt-get install -y upx
|
||
upx --version
|
||
|
||
# AppImage 运行/打包可能需要 FUSE2。不同发行版/版本包名不同,做兼容兜底。
|
||
sudo apt-get install -y libfuse2 || sudo apt-get install -y libfuse2t64 || true
|
||
|
||
# Download linuxdeploy tools for AppImage packaging
|
||
LINUXDEPLOY_URL="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
|
||
PLUGIN_URL="https://github.com/linuxdeploy/linuxdeploy-plugin-gtk/releases/download/continuous/linuxdeploy-plugin-gtk-x86_64.AppImage"
|
||
|
||
echo "📥 下载 linuxdeploy..."
|
||
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=3 \
|
||
-O /tmp/linuxdeploy "$LINUXDEPLOY_URL" || {
|
||
echo "⚠️ linuxdeploy 下载失败,AppImage 打包将跳过"
|
||
touch /tmp/skip-appimage
|
||
}
|
||
|
||
echo "📥 下载 linuxdeploy-plugin-gtk..."
|
||
wget --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 --tries=3 \
|
||
-O /tmp/linuxdeploy-plugin-gtk "$PLUGIN_URL" || {
|
||
echo "⚠️ linuxdeploy-plugin-gtk 下载失败,AppImage 打包将跳过"
|
||
touch /tmp/skip-appimage
|
||
}
|
||
|
||
if [ ! -f /tmp/skip-appimage ]; then
|
||
chmod +x /tmp/linuxdeploy /tmp/linuxdeploy-plugin-gtk
|
||
echo "✅ AppImage 工具准备完成"
|
||
fi
|
||
|
||
- name: Install Wails
|
||
run: go install -v github.com/wailsapp/wails/v2/cmd/wails@latest
|
||
|
||
- name: Setup MSYS2 Toolchain For DuckDB (Windows AMD64)
|
||
id: msys2_duckdb
|
||
if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' }}
|
||
continue-on-error: true
|
||
uses: msys2/setup-msys2@v2
|
||
with:
|
||
msystem: UCRT64
|
||
update: true
|
||
install: >-
|
||
mingw-w64-ucrt-x86_64-gcc
|
||
|
||
- name: Configure DuckDB CGO Toolchain (Windows AMD64)
|
||
if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' }}
|
||
shell: pwsh
|
||
run: |
|
||
function Find-MingwBin([string[]]$candidates) {
|
||
foreach ($bin in $candidates) {
|
||
if ([string]::IsNullOrWhiteSpace($bin)) {
|
||
continue
|
||
}
|
||
$gcc = Join-Path $bin 'gcc.exe'
|
||
$gxx = Join-Path $bin 'g++.exe'
|
||
if ((Test-Path $gcc) -and (Test-Path $gxx)) {
|
||
return $bin
|
||
}
|
||
}
|
||
return $null
|
||
}
|
||
|
||
$msys2Outcome = "${{ steps.msys2_duckdb.outcome }}"
|
||
$msys2Location = "${{ steps.msys2_duckdb.outputs['msys2-location'] }}"
|
||
$candidateBins = @()
|
||
if (-not [string]::IsNullOrWhiteSpace($msys2Location)) {
|
||
$candidateBins += Join-Path $msys2Location 'ucrt64\bin'
|
||
}
|
||
$candidateBins += @(
|
||
'C:\msys64\ucrt64\bin',
|
||
'D:\a\_temp\msys64\ucrt64\bin'
|
||
)
|
||
$candidateBins = @($candidateBins | Select-Object -Unique)
|
||
|
||
$mingwBin = Find-MingwBin $candidateBins
|
||
if (-not $mingwBin) {
|
||
if ($msys2Outcome -ne 'success') {
|
||
Write-Warning "⚠️ MSYS2 安装步骤结果为 $msys2Outcome,回退到 UCRT64 本机路径探测"
|
||
} else {
|
||
Write-Warning "⚠️ MSYS2 已执行,但未找到 UCRT64 gcc/g++,回退到本机路径探测"
|
||
}
|
||
$mingwBin = Find-MingwBin $candidateBins
|
||
}
|
||
|
||
if (-not $mingwBin) {
|
||
Write-Error "❌ 未找到可用的 DuckDB UCRT64 编译器。已检查:$($candidateBins -join ', ')"
|
||
exit 1
|
||
}
|
||
|
||
$gcc = (Join-Path $mingwBin 'gcc.exe')
|
||
$gxx = (Join-Path $mingwBin 'g++.exe')
|
||
|
||
if (!(Test-Path $gcc) -or !(Test-Path $gxx)) {
|
||
Write-Error "❌ DuckDB 编译器缺失:gcc=$gcc g++=$gxx"
|
||
exit 1
|
||
}
|
||
|
||
"$mingwBin" | Out-File -FilePath $env:GITHUB_PATH -Append -Encoding utf8
|
||
"CC=$gcc" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||
"CXX=$gxx" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
|
||
Write-Host "✅ 已配置 DuckDB cgo 编译器: gcc=$gcc g++=$gxx"
|
||
|
||
- name: Verify DuckDB CGO Toolchain (Windows AMD64)
|
||
if: ${{ matrix.build_optional_agents && matrix.platform == 'windows/amd64' }}
|
||
shell: pwsh
|
||
run: |
|
||
& "$env:CC" --version
|
||
& "$env:CXX" --version
|
||
|
||
- name: Build
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
if [ -n "${{ matrix.wails_tags }}" ]; then
|
||
wails build -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -tags "${{ matrix.wails_tags }}" -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${{ github.ref_name }}"
|
||
else
|
||
wails build -platform ${{ matrix.platform }} -clean -o ${{ matrix.build_name }} -ldflags "-s -w -X GoNavi-Wails/internal/app.AppVersion=${{ github.ref_name }}"
|
||
fi
|
||
|
||
- name: Build Optional Driver Agents
|
||
if: ${{ matrix.build_optional_agents }}
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
TARGET_PLATFORM="${{ matrix.platform }}"
|
||
GOOS="${TARGET_PLATFORM%%/*}"
|
||
GOARCH="${TARGET_PLATFORM##*/}"
|
||
DRIVERS=(mariadb doris sphinx sqlserver sqlite duckdb dameng kingbase highgo vastbase mongodb tdengine clickhouse)
|
||
OUTDIR="drivers/${{ matrix.os_name }}"
|
||
mkdir -p "$OUTDIR"
|
||
|
||
for DRIVER in "${DRIVERS[@]}"; do
|
||
BUILD_DRIVER="$DRIVER"
|
||
if [ "$DRIVER" = "doris" ]; then
|
||
BUILD_DRIVER="diros"
|
||
fi
|
||
if [ "$DRIVER" = "duckdb" ] && [ "$GOOS" = "windows" ] && [ "$GOARCH" != "amd64" ]; then
|
||
echo "⚠️ 跳过 DuckDB driver(当前平台 ${GOOS}/${GOARCH} 不受支持,仅支持 windows/amd64)"
|
||
continue
|
||
fi
|
||
TAG="gonavi_${BUILD_DRIVER}_driver"
|
||
OUTPUT="${DRIVER}-driver-agent-${GOOS}-${GOARCH}"
|
||
if [ "$GOOS" = "windows" ]; then
|
||
OUTPUT="${OUTPUT}.exe"
|
||
fi
|
||
OUTPUT_PATH="${OUTDIR}/${OUTPUT}"
|
||
echo "🔧 构建 ${OUTPUT_PATH} (tag=${TAG})"
|
||
if [ "$DRIVER" = "duckdb" ]; then
|
||
CGO_ENABLED=1 GOOS="$GOOS" GOARCH="$GOARCH" go build \
|
||
-tags "${TAG}" \
|
||
-trimpath \
|
||
-ldflags "-s -w" \
|
||
-o "${OUTPUT_PATH}" \
|
||
./cmd/optional-driver-agent
|
||
else
|
||
CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" go build \
|
||
-tags "${TAG}" \
|
||
-trimpath \
|
||
-ldflags "-s -w" \
|
||
-o "${OUTPUT_PATH}" \
|
||
./cmd/optional-driver-agent
|
||
fi
|
||
done
|
||
|
||
# macOS Packaging
|
||
- name: Package macOS DMG
|
||
if: contains(matrix.platform, 'darwin')
|
||
run: |
|
||
brew install create-dmg
|
||
VERSION="${{ github.ref_name }}"
|
||
VERSION="${VERSION#v}"
|
||
cd build/bin
|
||
|
||
APP_PATH=$(find . -maxdepth 1 -name "*.app" | head -n 1)
|
||
if [ -z "$APP_PATH" ]; then
|
||
echo "❌ 未找到 .app 应用包!"
|
||
exit 1
|
||
fi
|
||
APP_NAME=$(basename "$APP_PATH")
|
||
|
||
APP_BIN=$(find "$APP_PATH/Contents/MacOS" -maxdepth 1 -type f | head -n 1)
|
||
if [ -z "$APP_BIN" ]; then
|
||
echo "❌ 未找到 macOS 应用主程序,无法进行 UPX 压缩!"
|
||
exit 1
|
||
fi
|
||
BEFORE_BYTES=$(wc -c <"$APP_BIN" | tr -d '[:space:]')
|
||
echo "🗜️ 正在使用 UPX 压缩 macOS 可执行文件: $APP_BIN ..."
|
||
upx --best --lzma --force "$APP_BIN"
|
||
upx -t "$APP_BIN"
|
||
AFTER_BYTES=$(wc -c <"$APP_BIN" | tr -d '[:space:]')
|
||
if [ "$AFTER_BYTES" -lt "$BEFORE_BYTES" ]; then
|
||
SAVED_BYTES=$((BEFORE_BYTES - AFTER_BYTES))
|
||
awk -v b="$BEFORE_BYTES" -v a="$AFTER_BYTES" -v s="$SAVED_BYTES" 'BEGIN { printf "✅ macOS UPX 压缩完成:%.2fMB -> %.2fMB,减少 %.2fMB\n", b/1024/1024, a/1024/1024, s/1024/1024 }'
|
||
else
|
||
awk -v b="$BEFORE_BYTES" -v a="$AFTER_BYTES" 'BEGIN { printf "ℹ️ macOS UPX 压缩完成:%.2fMB -> %.2fMB\n", b/1024/1024, a/1024/1024 }'
|
||
fi
|
||
|
||
echo "🔏 正在进行 Ad-hoc 签名..."
|
||
# 注意:Ad-hoc + hardened runtime(--options runtime)在未配置 entitlements 时,
|
||
# 可能导致部分 macOS 机型上应用双击无响应。这里保持 Ad-hoc 深签名但禁用 runtime hardened。
|
||
codesign --force --deep --sign - "$APP_NAME"
|
||
|
||
DMG_NAME="${{ matrix.build_name }}.dmg"
|
||
FINAL_NAME="GoNavi-$VERSION-${{ matrix.os_name }}-${{ matrix.arch_name }}${{ matrix.artifact_suffix }}.dmg"
|
||
echo "📦 正在生成 DMG: $DMG_NAME..."
|
||
|
||
create-dmg \
|
||
--volname "GoNavi Installer" \
|
||
--window-pos 200 120 \
|
||
--window-size 800 400 \
|
||
--icon-size 100 \
|
||
--icon "$APP_NAME" 200 190 \
|
||
--hide-extension "$APP_NAME" \
|
||
--app-drop-link 600 185 \
|
||
"$DMG_NAME" \
|
||
"$APP_NAME"
|
||
|
||
mv "$DMG_NAME" "../../$FINAL_NAME"
|
||
|
||
# Windows Packaging
|
||
- name: Package Windows EXE
|
||
if: contains(matrix.platform, 'windows')
|
||
shell: pwsh
|
||
run: |
|
||
Set-Location build/bin
|
||
$version = "${{ github.ref_name }}"
|
||
if ($version.StartsWith("v")) {
|
||
$version = $version.Substring(1)
|
||
}
|
||
$target = "${{ matrix.build_name }}"
|
||
$finalExeName = "GoNavi-$version-${{ matrix.os_name }}-${{ matrix.arch_name }}${{ matrix.artifact_suffix }}.exe"
|
||
|
||
if (Test-Path "$target.exe") {
|
||
$finalExe = "$target.exe"
|
||
} elseif (Test-Path "$target") {
|
||
Rename-Item -Path "$target" -NewName "$target.exe"
|
||
$finalExe = "$target.exe"
|
||
} else {
|
||
Write-Error "❌ 未找到构建产物 '$target'!"
|
||
exit 1
|
||
}
|
||
|
||
$upxCmd = Get-Command upx -ErrorAction SilentlyContinue
|
||
if ($null -eq $upxCmd) {
|
||
Write-Error "❌ 未找到 upx,无法保证 Windows 产物经过压缩"
|
||
exit 1
|
||
}
|
||
$beforeBytes = (Get-Item -LiteralPath $finalExe).Length
|
||
Write-Host "🗜️ 使用 UPX 压缩 $finalExe ..."
|
||
& upx --best --lzma --force $finalExe | Out-Host
|
||
& upx -t $finalExe | Out-Host
|
||
$afterBytes = (Get-Item -LiteralPath $finalExe).Length
|
||
if ($afterBytes -lt $beforeBytes) {
|
||
$savedBytes = $beforeBytes - $afterBytes
|
||
Write-Host ("✅ UPX 压缩完成:{0:N2}MB -> {1:N2}MB,减少 {2:N2}MB" -f ($beforeBytes / 1MB), ($afterBytes / 1MB), ($savedBytes / 1MB))
|
||
} else {
|
||
Write-Host ("ℹ️ UPX 压缩完成:{0:N2}MB -> {1:N2}MB" -f ($beforeBytes / 1MB), ($afterBytes / 1MB))
|
||
}
|
||
|
||
Write-Host "📦 输出 Windows 可执行文件 $finalExeName..."
|
||
Copy-Item -LiteralPath $finalExe -Destination "..\\..\\$finalExeName" -Force
|
||
|
||
# Linux Packaging (tar.gz and AppImage)
|
||
- name: Package Linux
|
||
if: contains(matrix.platform, 'linux')
|
||
run: |
|
||
VERSION="${{ github.ref_name }}"
|
||
VERSION="${VERSION#v}"
|
||
cd build/bin
|
||
TARGET="${{ matrix.build_name }}"
|
||
TAR_NAME="GoNavi-$VERSION-${{ matrix.os_name }}-${{ matrix.arch_name }}${{ matrix.artifact_suffix }}.tar.gz"
|
||
APPIMAGE_NAME="GoNavi-$VERSION-${{ matrix.os_name }}-${{ matrix.arch_name }}${{ matrix.artifact_suffix }}.AppImage"
|
||
|
||
if [ ! -f "$TARGET" ]; then
|
||
echo "❌ 未找到构建产物 '$TARGET'!"
|
||
exit 1
|
||
fi
|
||
|
||
chmod +x "$TARGET"
|
||
BEFORE_BYTES=$(wc -c <"$TARGET" | tr -d '[:space:]')
|
||
echo "🗜️ 正在使用 UPX 压缩 Linux 可执行文件: $TARGET ..."
|
||
upx --best --lzma --force "$TARGET"
|
||
upx -t "$TARGET"
|
||
AFTER_BYTES=$(wc -c <"$TARGET" | tr -d '[:space:]')
|
||
if [ "$AFTER_BYTES" -lt "$BEFORE_BYTES" ]; then
|
||
SAVED_BYTES=$((BEFORE_BYTES - AFTER_BYTES))
|
||
awk -v b="$BEFORE_BYTES" -v a="$AFTER_BYTES" -v s="$SAVED_BYTES" 'BEGIN { printf "✅ Linux UPX 压缩完成:%.2fMB -> %.2fMB,减少 %.2fMB\n", b/1024/1024, a/1024/1024, s/1024/1024 }'
|
||
else
|
||
awk -v b="$BEFORE_BYTES" -v a="$AFTER_BYTES" 'BEGIN { printf "ℹ️ Linux UPX 压缩完成:%.2fMB -> %.2fMB\n", b/1024/1024, a/1024/1024 }'
|
||
fi
|
||
|
||
# 1. Create tar.gz
|
||
echo "📦 正在打包 $TAR_NAME..."
|
||
tar -czvf "$TAR_NAME" "$TARGET"
|
||
mv "$TAR_NAME" ../../
|
||
|
||
# 2. Create AppImage (skip for ARM64 or if tools unavailable)
|
||
if [ -f /tmp/skip-appimage ]; then
|
||
echo "⚠️ 跳过 AppImage 打包"
|
||
exit 0
|
||
fi
|
||
|
||
echo "📦 正在生成 AppImage..."
|
||
|
||
# Create AppDir structure
|
||
mkdir -p AppDir/usr/bin
|
||
mkdir -p AppDir/usr/share/applications
|
||
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
|
||
|
||
cp "$TARGET" AppDir/usr/bin/gonavi
|
||
|
||
# Create desktop file
|
||
printf '%s\n' \
|
||
'[Desktop Entry]' \
|
||
'Name=GoNavi' \
|
||
'Exec=gonavi' \
|
||
'Icon=gonavi' \
|
||
'Type=Application' \
|
||
'Categories=Development;Database;' \
|
||
'Comment=Database Management Tool' \
|
||
> AppDir/usr/share/applications/gonavi.desktop
|
||
|
||
cp AppDir/usr/share/applications/gonavi.desktop AppDir/gonavi.desktop
|
||
|
||
# Create a simple icon (or use existing if available)
|
||
if [ -f "../../build/appicon.png" ]; then
|
||
cp "../../build/appicon.png" AppDir/usr/share/icons/hicolor/256x256/apps/gonavi.png
|
||
cp "../../build/appicon.png" AppDir/gonavi.png
|
||
else
|
||
# Create a placeholder icon
|
||
convert -size 256x256 xc:#336791 -fill white -gravity center -pointsize 48 -annotate 0 "GoNavi" AppDir/gonavi.png || \
|
||
wget -q "https://via.placeholder.com/256/336791/FFFFFF?text=GoNavi" -O AppDir/gonavi.png || \
|
||
touch AppDir/gonavi.png
|
||
cp AppDir/gonavi.png AppDir/usr/share/icons/hicolor/256x256/apps/gonavi.png
|
||
fi
|
||
|
||
# Build AppImage
|
||
export DEPLOY_GTK_VERSION=3
|
||
/tmp/linuxdeploy --appdir AppDir --plugin gtk --output appimage || {
|
||
echo "⚠️ AppImage 生成失败,但 tar.gz 已成功生成"
|
||
exit 0
|
||
}
|
||
|
||
# Rename output
|
||
mv GoNavi*.AppImage "$APPIMAGE_NAME" 2>/dev/null || {
|
||
echo "⚠️ AppImage 重命名失败"
|
||
exit 0
|
||
}
|
||
|
||
if [ -f "$APPIMAGE_NAME" ]; then
|
||
mv "$APPIMAGE_NAME" ../../
|
||
echo "✅ AppImage 生成成功"
|
||
fi
|
||
|
||
# Upload to Actions Artifacts (Temporary Storage)
|
||
- name: Upload Artifact
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: build-artifacts-${{ strategy.job-index }} # Unique name per job
|
||
path: |
|
||
GoNavi-*.dmg
|
||
GoNavi-*.exe
|
||
GoNavi-*.tar.gz
|
||
GoNavi-*.AppImage
|
||
drivers/**
|
||
retention-days: 1
|
||
|
||
# Phase 2: Collect all artifacts and Publish Release (Single Job)
|
||
release:
|
||
name: Publish Release
|
||
needs: build
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Download All Artifacts
|
||
uses: actions/download-artifact@v4
|
||
with:
|
||
path: release-assets
|
||
pattern: build-artifacts-*
|
||
merge-multiple: true
|
||
|
||
- name: List Assets
|
||
run: ls -R release-assets
|
||
|
||
- name: Verify Optional Driver Assets
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
cd release-assets
|
||
|
||
REQUIRED_FILES=(
|
||
"drivers/Windows/duckdb-driver-agent-windows-amd64.exe"
|
||
"drivers/MacOS/duckdb-driver-agent-darwin-amd64"
|
||
"drivers/MacOS/duckdb-driver-agent-darwin-arm64"
|
||
"drivers/Linux/duckdb-driver-agent-linux-amd64"
|
||
"drivers/Windows/clickhouse-driver-agent-windows-amd64.exe"
|
||
"drivers/MacOS/clickhouse-driver-agent-darwin-amd64"
|
||
"drivers/MacOS/clickhouse-driver-agent-darwin-arm64"
|
||
"drivers/Linux/clickhouse-driver-agent-linux-amd64"
|
||
)
|
||
|
||
missing=0
|
||
for file in "${REQUIRED_FILES[@]}"; do
|
||
if [ ! -f "$file" ]; then
|
||
echo "❌ 缺少驱动资产:$file"
|
||
missing=1
|
||
else
|
||
echo "✅ 已找到驱动资产:$file"
|
||
fi
|
||
done
|
||
|
||
if [ "$missing" -ne 0 ]; then
|
||
echo "❌ 可选驱动资产不完整,终止发布"
|
||
exit 1
|
||
fi
|
||
|
||
- name: Package Driver Agents Bundle
|
||
shell: bash
|
||
run: |
|
||
set -euo pipefail
|
||
cd release-assets
|
||
if [ ! -d drivers ]; then
|
||
echo "⚠️ 未找到 drivers 目录,跳过驱动总包打包"
|
||
exit 0
|
||
fi
|
||
if [ -z "$(find drivers -type f 2>/dev/null | head -n 1)" ]; then
|
||
echo "⚠️ drivers 目录为空,跳过驱动总包打包"
|
||
rm -rf drivers
|
||
exit 0
|
||
fi
|
||
|
||
echo "📦 打包驱动总包:GoNavi-DriverAgents.zip"
|
||
python3 - <<'PY'
|
||
import json
|
||
import os
|
||
import zipfile
|
||
from pathlib import Path
|
||
|
||
out_name = "GoNavi-DriverAgents.zip"
|
||
index_name = "GoNavi-DriverAgents-Index.json"
|
||
base = Path("drivers")
|
||
out_path = Path(out_name)
|
||
index_path = Path(index_name)
|
||
if out_path.exists():
|
||
out_path.unlink()
|
||
if index_path.exists():
|
||
index_path.unlink()
|
||
|
||
size_index = {}
|
||
with zipfile.ZipFile(out_path, "w", compression=zipfile.ZIP_DEFLATED) as zf:
|
||
for p in base.rglob("*"):
|
||
if not p.is_file():
|
||
continue
|
||
arcname = p.relative_to(base).as_posix()
|
||
zf.write(p, arcname)
|
||
size_index[p.name] = p.stat().st_size
|
||
|
||
index_path.write_text(
|
||
json.dumps({"assets": size_index}, ensure_ascii=False, indent=2),
|
||
encoding="utf-8",
|
||
)
|
||
|
||
print(f"created {out_name} size={out_path.stat().st_size} bytes")
|
||
print(f"created {index_name} entries={len(size_index)}")
|
||
PY
|
||
|
||
# Release 只发布一个驱动总包,避免大量平铺资产污染 Release 页面
|
||
rm -rf drivers
|
||
|
||
- name: Generate SHA256SUMS
|
||
shell: bash
|
||
run: |
|
||
cd release-assets
|
||
FILES=()
|
||
while IFS= read -r file; do
|
||
if [ -n "$file" ]; then
|
||
FILES+=("$file")
|
||
fi
|
||
done < <(find . -maxdepth 1 -type f ! -name SHA256SUMS -exec basename {} \; | sort)
|
||
if [ ${#FILES[@]} -eq 0 ]; then
|
||
echo "⚠️ 未找到可签名资产,生成空 SHA256SUMS"
|
||
: > SHA256SUMS
|
||
else
|
||
sha256sum "${FILES[@]}" > SHA256SUMS
|
||
fi
|
||
|
||
- name: Create Release
|
||
uses: softprops/action-gh-release@v2
|
||
if: startsWith(github.ref, 'refs/tags/')
|
||
with:
|
||
files: release-assets/*
|
||
draft: true
|
||
make_latest: true
|
||
generate_release_notes: true
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|