Files
arcrun-collector/cmd/arcrun-app/build-dmg.sh
T
Leo a55488040d Windows 交付改單一 exe+版本號不再手打(leo 08-06 回報②與「整串該機械化」)
## ② 兩個檔很迷惑 → 一個檔
leo 圖一標註:「下載還是 ZIP ⇒ 應該是 MSIX 或 EXE;解開還是 2 個檔 ⇒ 應該只有 1 個檔案」。
舊做法 zip 裡放 Arcrun.exe+arcrun-collector.exe 同層,少解一個檔就永遠不會同步,
而畫面不會說是這個原因。
修:collector 用 go:embed 收進 Arcrun.exe,第一次執行攤到 ~/.arcrun-rag/bin/
    (冪等:sha256 相同不重寫;先寫暫存再 rename,避免留半截執行檔)。
    build-win.sh 直接產單一 Arcrun-win-<ver>.exe,不再打 zip。
    加機械閘:產出的 exe 若比 collector 還小 ⇒ 沒 embed 成功 ⇒ 中止(過去只會
    默默得到一顆「裝了也不會同步」的空殼)。
不走 MSIX:未上架的 MSIX 要使用者先開「開發人員模式」,比 zip 更麻煩。

## 版本號機械化(leo:「這一整串都應該是機械化,不應該每次手工做」)
病根實測:本 repo **一個 git tag 都沒有**,而四支 build 腳本寫的是
`git describe --tags` ⇒ 永遠拿不到 v0.18.x ⇒ 只能靠打包時人工敲 VERSION=
⇒ 兩條打包線各敲各的 ⇒ manifest 宣告 0.18.5、產物其實是 0.18.4。

修:新增 daemon-version.sh 當唯一產生器,沿用 release.mjs 已在跑的原則
   (「版本號由內容算出來,不是由人宣告」),不另立新制:
     MINOR ← DAEMON_LINE(人決定,大改版才動)
     PATCH ← 動過 collector/ 的 commit 數 − DAEMON_PATCH_BASE(機器決定)
   ⇒ 沒改 daemon 重跑打包不會虛增;改了才 +1;四支腳本在同一 commit 必得同號。
   ⇒ 不需要 git tag/Actions/輪詢(守 D20 紅線)。
   校準:DAEMON_LINE=0.18、BASE=87 ⇒ 現在的樹算出 v0.18.7(上次出貨過 0.18.6)。
   build-win/mac/dmg/msix 四支全部改用它。

## icon 漂移根治接上打包
build-win.sh 步驟⓪ 每次都跑 gen-icons.py 重產 icon.ico/trayicon.ico。

## 驗(實測輸出,非推測)
· ./build-win.sh 全程跑通,產出 dist/Arcrun-win-v0.18.7.exe(27,445,248 bytes)
· strings 抽內嵌版本 = v0.18.7、buildTime = 20260806-1233(機器算的,沒人敲)
· 位元組比對該 exe:
    CIS trayicon 在裡面        = True
    Wails「W」圖還在           = False
    collector 有 embed 進去    = True(16,104,960 bytes)
· go vet 全綠(darwin + windows);mac build OK
· 未驗:Windows 真機行為(需封測者實跑)⇒ 狀態 ◐,不是 
· 未做:CHANGELOG 閘、manifest「宣告版本 == 產物版本」驗證閘、前端顯示版本與下載入口
2026-08-06 12:35:54 +08:00

77 lines
3.5 KiB
Bash
Executable File
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.
#!/usr/bin/env bash
# build-dmg.sh — 打包成 Mac 標準安裝檔(t194,leo:「你應該包成 Mac 安裝檔,我完整做一次」)
#
# DMG 裡放 Arcrun.app Applications 捷徑 ⇒ 開啟就是「把 App 拖進去」的標準畫面。
# 為什麼一定要:使用者若直接在下載資料夾裡跑,自更新會蓋錯位置(t184 Oscar 的病);
# 而且 macOS 對「不在 /Applications 的常駐程式」權限行為也不一致。
set -euo pipefail
cd "$(dirname "$0")"
# 🔴 2026-08-06:版本號改由 daemon-version.sh 機械產生(不再手打/不靠 git describe)。
# 病根:本 repo 一個 git tag 都沒有 ⇒ git describe 永遠拿不到 v0.18.x
# ⇒ 只能靠打包時人工敲 VERSION= ⇒ 兩條打包線各敲各的 ⇒ manifest 說謊。
# 理由與算法全文見 daemon-version.sh。
VERSION="${VERSION:-$(./daemon-version.sh)}"
echo "① 先確保 .app 是最新的"
VERSION="$VERSION" bash build-mac.sh >/dev/null
APP="build/bin/Arcrun.app"
[ -d "$APP" ] || { echo "❌ 找不到 $APP" >&2; exit 1; }
OUT="dist"; DMG="$OUT/Arcrun-${VERSION}.dmg"
STAGE="$(mktemp -d)/Arcrun"
mkdir -p "$OUT" "$STAGE"
echo "② 放 app Applications 捷徑"
ditto "$APP" "$STAGE/Arcrun.app"
ln -s /Applications "$STAGE/Applications"
echo "③ 產可寫 DMG-fs HFS+:否則含空格/中文的名稱會被截斷)"
rm -f "$DMG"
RW="$(mktemp -d)/rw.dmg"
hdiutil create -volname "Arcrun" -srcfolder "$STAGE" -fs HFS+ -ov -format UDRW "$RW" >/dev/null
rm -rf "$(dirname "$STAGE")"
# ── ④ 排版面:讓「拖進去」這件事一眼可見 ────────────────────────────────────
# 🔴 leo 2026-08-05:「要跳出虛擬隨身碟,打開一個 finder 的視窗,**顯示 Arcrun 和
# Application 的捷徑**,用戶把 App 拖進 Application」。
# 光是「裡面有兩個項目」不夠——預設是清單視圖、位置隨機,使用者看不出「要往右拖」。
# ⇒ 設成大圖示、固定視窗大小、兩個 icon 左右並排。
# best-effortFinder 自動化在沒有桌面工作階段時(ssh/CI)會失敗,
# 失敗只警告不中止——版面是加分,DMG 本身照樣可用,不該讓打包整個掛掉。
hdiutil attach "$RW" -noautoopen -quiet
if osascript <<'APPLESCRIPT' >/dev/null 2>&1
tell application "Finder"
tell disk "Arcrun"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {200, 160, 800, 560}
set vopts to the icon view options of container window
set arrangement of vopts to not arranged
set icon size of vopts to 128
set position of item "Arcrun.app" of container window to {150, 190}
set position of item "Applications" of container window to {450, 190}
update without registering applications
close
end tell
end tell
APPLESCRIPT
then
echo " ✅ 版面已設定(大圖示,Arcrun 在左、Applications 在右)"
else
echo " ⚠️ Finder 版面設定失敗(多半是沒有桌面工作階段)——DMG 仍可用,只是視圖是預設值" >&2
fi
sync
hdiutil detach "/Volumes/Arcrun" -quiet
echo "⑤ 壓成唯讀發佈檔"
hdiutil convert "$RW" -format UDZO -o "$DMG" >/dev/null
rm -rf "$(dirname "$RW")"
SIZE=$(ls -lh "$DMG" | awk '{print $5}')
echo "✅ 完成:${DMG}${SIZE}"
echo
echo "🔬 使用者流程:開 DMG → 把 Arcrun 拖到 Applications → 退出這個虛擬磁碟 → 從啟動台開啟"