Files
arcrun-collector/cmd/arcrun-app/build-mac.sh
T
Leo bd25efaae5 refactor(collector): 剪掉臍帶——collector/ 自己就算得出自己的版本號(D95 第一輪②)
leo 2026-08-17:「身為管理者,你要從頭到尾**不要有很多扭曲**,因為你根本不記得
你做的這些扭曲,**每次都要查**,很直接,源碼、產出物,從 stage 到 prod。」

`collector/` 原本要伸手到 repo 根才算得出自己的版本,共四條:

  ① `daemon-version.py` 讀 `docs-site/src/content/docs/help/changelog.md`
  ② `daemon-version.py` 讀 `ROOT/DAEMON_LINE`
  ③ `daemon-version.py` 的原始碼指紋從 repo 根 `git ls-files collector`
  ④ `changelog-section.sh` 讀 `$REPO_ROOT/docs-site/...` 並 exec
     `$REPO_ROOT/installer/scripts/daemon-notes.mjs`
  ⑤(複驗才發現的第五條)`build-msix.sh` 用 `git rev-parse --show-toplevel`/../../.env
     推 InkStoneCo 頂層拿 MS Store Identity

現在全部落在 `collector/` 內部:

  · `collector/CHANGELOG.md`  ← 新家。**原檔同時裝著兩條版本線**
    (桌面版 `v0.18.x` + 雲端引擎 `1.4.x`),已按版號格式拆開;
    雲端那 17 段原地不動留在 docs-site,桌面版這 30 段搬過來。
  · `collector/DAEMON_LINE`   ← 從 repo 根搬進來
  · 指紋改以 `collector/` 為根算(`cwd=COLLECTOR`、pathspec `.`)
    ⇒ 相對路徑前綴變了、而路徑有進雜湊 ⇒ `FINGERPRINT_ALGO` 3→4,
      照既有設計讓帳本自動整本作廢重記(不要手改 JSON)
  · `daemon-notes.mjs` 實作搬進 `collector/cmd/arcrun-app/`,
    `installer/scripts/daemon-notes.mjs` 變薄殼轉呼叫
    ⇒ **根可以往內伸手,collector 不可以往外伸手**,方向單向
  · `build-msix.sh` 改成往上找「帶著那把鍵的 .env」,
    leo 08-06「腳本自己去讀不要再問人」原樣保留,但不再綁目錄結構

驗收閘:`collector/check-standalone.sh`——不是 grep,是**行為證明**:
把 collector/ 的檔案單獨複製到 repo 之外的臨時目錄、在那裡 git init,
再跑版本計算與打包前置閘。跑得起來=真的自足。

自己發現並修掉的三件:
  · `arcrun-tray/assets/store/` 與 `--setup` 其實還活著(見上一顆 commit)
  · 兩支同名的 `daemon-notes.mjs` CLI 守衛比的是**檔名尾綴**
    ⇒ 兩支一起開火,問雲端版號時 collector 那支先 exit(1),
      薄殼根本沒機會查 docs-site。改成比絕對路徑。
  · `collector/CHANGELOG.md` 的「怎麼出新版」說明若照抄那行標題,
    會被 `daemon-version.py` 的純字串比對當成「有待發佈內容」而誤升版
    ⇒ 說明裡刻意不寫成真的標題,並把這個邊角寫在檔案裡

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-18 13:05:33 +08:00

64 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-mac.sh — 打包 Arcrun.appWails 版,t194
#
# 與 fyne 版最重要的差別:**要把 collector 同綑進 .app**。
# daemon 的本體是 `collector direct`(監看/萃卡/上傳),App 只是它的門面;
# 沒同綑 ⇒ 裝了也不會同步。
set -euo pipefail
cd "$(dirname "$0")"
# 🔴 2026-08-06:版本號改由 daemon-version.py 機械產生(不再手打/不靠 git describe)。
# 病根:本 repo 一個 git tag 都沒有 ⇒ git describe 永遠拿不到 v0.18.x
# ⇒ 只能靠打包時人工敲 VERSION= ⇒ 兩條打包線各敲各的 ⇒ manifest 說謊。
# 理由與算法全文見 daemon-version.py。
VERSION="${VERSION:-$(./daemon-version.py --stamp)}"
# 🔴 2026-08-06 機械閘:這一版的「更新內容」沒寫進 changelog ⇒ 不准打包。
# leo:「給版本號、本版更新內容、打包產品、顯示在前端,這一整串都應該是機械化」。
# 單一真相源=collector/CHANGELOG.mdmanifest.notes 與前端全部投影自它。
# 2026-08-18 D95 第一輪:從 docs-site 搬進 collector/daemon 才算得出自己的版本。)
# 理由與格式見 changelog-section.sh。
./changelog-section.sh "$VERSION" --check
BUILD_TIME="$(date '+%Y%m%d-%H%M')"
LDFLAGS_VER="-X main.version=${VERSION} -X main.buildTime=${BUILD_TIME} -X arcrun-rag/collector.version=${VERSION} -X arcrun-rag/collector.buildTime=${BUILD_TIME}"
export PATH="$PATH:$(go env GOPATH)/bin"
echo "🏷 版本:${VERSION}build ${BUILD_TIME}"
# 🔴 2026-08-06 起**不再單獨編 collector**(leo:「不要兩支,寫成一支檔案」)。
# collector 已改成可被引用的套件,直接編進同一個執行檔,靠 `--collector` 換身分。
# Mac 這邊原本是 .app 裡放兩個執行檔(沒有 dropper 問題),但兩邊做法統一才不會再漂移
# ——「Mac 有、Windows 漏了」這種病本 repo 已經犯過兩次(2b83c47、v0.18.6 版本注入)。
# 🔴 2026-08-05leo 開 DMG 檢查時抓到):Info.plist 的 CFBundleShortVersionString
# 是 **1.0.0**(Wails 預設),不是我們的版本號——因為 wails.json 沒有 info.productVersion
# 而 `wails build` **沒有** CLI 旗標可指定。
# ⇒ 建置前把版本寫進 wails.json 的 info,建完還原(不污染版控)。
# 為什麼要修:使用者「關於」看到的、以及 Finder 顯示的版本都讀這個欄位;
# 永遠顯示 1.0.0 ⇒ 用戶無從判斷自己是不是新版(同 leo「版本號是唯一驗收介面」的病)。
PLIST_VER="${VERSION#v}"
cp wails.json wails.json.bak
python3 - "$PLIST_VER" <<'PY'
import json, sys
c = json.load(open('wails.json'))
c.setdefault('info', {})
c['info']['productVersion'] = sys.argv[1]
c['info']['productName'] = 'Arcrun'
json.dump(c, open('wails.json', 'w'), indent=2, ensure_ascii=False)
PY
trap 'mv -f wails.json.bak wails.json 2>/dev/null || true' EXIT
echo "② wails build"
wails build -clean -ldflags "${LDFLAGS_VER}"
APP="build/bin/Arcrun.app"
[ -d "build/bin/arcrun-app.app" ] && { rm -rf "$APP"; mv "build/bin/arcrun-app.app" "$APP"; }
echo "③ 同綑 collector 進 .appApp 用 os.Executable() 找同層)"
echo "④ ad-hoc 重簽(改過 bundle 內容必重簽,否則 launchd 拒開)"
codesign --force --deep --sign - "$APP" 2>/dev/null || true
echo "✅ 完成:$APP"
echo " 驗法:open '$APP' → 選單列出現 icon、Dock **不出現** icon"
echo " 點 icon → 立刻展開視窗;右鍵 → 只有「結束 Arcrun」"