Files
arcrun-collector/cmd/arcrun-app/build-msix.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

119 lines
5.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-msix.sh — 把 Wails 版 Arcrun 打包成 Microsoft Store 用的 .msixt1962026-08-05
#
# leo 08-05:「當測試者給我截圖安裝成功就要提交 ms store」
#
# 🎯 **在 Mac 上就打得出 msix**,不需要 Windows 機器、不需要 MakeAppx。
# 靠微軟自家開源跨平台工具 msix-packaging 的 `makemsix`。
#
# ⚠️ **不必自購簽章憑證**:送 Store 的 msix 不用簽——微軟過審後會用自己的憑證重簽。
# 但**側載**(不走 Store)就必須自己簽。(官方說明見 ../arcrun-tray/docs/store-submission.md §2
#
# 與舊 fyne 版(../arcrun-tray/build-msix.sh)的差別:
# 舊版是單一 execollector 用 //go:embed 吃進去);
# **Wails 版是兩個 exe**Arcrun.exe arcrun-collector.exe,見 supervise.go 的
# os.Executable() 同層查找)⇒ 兩個都要進 msix root,缺一個就「裝了不會同步」。
#
# 前置(一次就好):
# brew install mingw-w64 cmake icu4c
# bash ../arcrun-tray/build-msix.sh --setup # 建 makemsix(約 5-10 分鐘)
#
# 用法:
# IDENTITY_NAME=<Partner Center 的 Name> \
# PUBLISHER=<Partner Center 的 Publisher> \
# PUBLISHER_DISPLAY=<顯示名> \
# bash build-msix.sh
set -euo pipefail
cd "$(dirname "$0")"
MSIX_SDK_DIR="${MSIX_SDK_DIR:-$HOME/.cache/msix-packaging}"
MAKEMSIX="$MSIX_SDK_DIR/.vs/bin/makemsix"
[[ -x "$MAKEMSIX" ]] || {
echo "❌ 找不到 makemsix$MAKEMSIX"
echo " 先跑一次:bash ../arcrun-tray/build-msix.sh --setup"
exit 1
}
VERSION_RAW="${VERSION:-$(./daemon-version.sh)}" # 版本由 daemon-version.sh 機械產生(2026-08-06
# msix 版本必須是四段數字 a.b.c.d,且**最後一段必須是 0**(Store 規定,保留給微軟)。
MSIX_VERSION="$(echo "$VERSION_RAW" | sed 's/^v//' | awk -F. '{printf "%d.%d.%d.0", $1, $2, $3}')"
# ⚠️ 變數後緊接全形括號必須用 ${} 包起來——全形字元會被 bash 當成變數名的一部分。
echo "🏷 msix 版本:${MSIX_VERSION}(來源 ${VERSION_RAW}"
# Identity 三值——**必須與 Partner Center 完全一致**,故從環境變數帶入,預設佔位。
IDENTITY_NAME="${IDENTITY_NAME:-PLACEHOLDER.ArcrunRAG}"
PUBLISHER="${PUBLISHER:-CN=PLACEHOLDER}"
PUBLISHER_DISPLAY="${PUBLISHER_DISPLAY:-PLACEHOLDER}"
if [[ "$IDENTITY_NAME" == PLACEHOLDER* ]]; then
echo "⚠️ Identity 仍是佔位值——**這顆 msix 不能送 Store**,只能拿來驗打包流程。"
echo " 送審前要帶:IDENTITY_NAME / PUBLISHER / PUBLISHER_DISPLAY(三值從 Partner Center 抄)"
fi
echo "① 編 Windows 版(兩個 exe"
VERSION="$VERSION_RAW" bash build-win.sh >/dev/null
[[ -f build/bin/arcrun-app.exe ]] || { echo "❌ Arcrun.exe 沒編出來" >&2; exit 1; }
[[ -f arcrun-collector.exe ]] || { echo "❌ collector.exe 沒編出來" >&2; exit 1; }
OUT="dist-msix"
rm -rf "$OUT" && mkdir -p "$OUT/root/Assets"
cp build/bin/arcrun-app.exe "$OUT/root/Arcrun.exe"
cp arcrun-collector.exe "$OUT/root/arcrun-collector.exe"
echo "② 複製 Store 圖示(沿用 CIS 版,不重產——sips 縮放會把方形拉扁)"
cp ../arcrun-tray/assets/store/*.png "$OUT/root/Assets/"
echo "③ 寫 AppxManifest.xml(能力宣告誠實且最小化)"
cat > "$OUT/root/AppxManifest.xml" <<EOF
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
IgnorableNamespaces="uap rescap">
<Identity Name="$IDENTITY_NAME" Publisher="$PUBLISHER" Version="$MSIX_VERSION" ProcessorArchitecture="x64" />
<Properties>
<DisplayName>Arcrun</DisplayName>
<PublisherDisplayName>$PUBLISHER_DISPLAY</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.17763.0" MaxVersionTested="10.0.22631.0" />
</Dependencies>
<Resources>
<Resource Language="zh-TW" />
<Resource Language="en-US" />
</Resources>
<Applications>
<Application Id="Arcrun" Executable="Arcrun.exe" EntryPoint="Windows.FullTrustApplication">
<uap:VisualElements
DisplayName="Arcrun"
Description="把你選的資料夾變成可以問問題的知識庫,檔案留在自己電腦裡。"
BackgroundColor="#17181A"
Square150x150Logo="Assets\Square150x150Logo.png"
Square44x44Logo="Assets\Square44x44Logo.png">
<uap:DefaultTile
Wide310x150Logo="Assets\Wide310x150Logo.png"
Square71x71Logo="Assets\Square71x71Logo.png"
Square310x310Logo="Assets\Square310x310Logo.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<rescap:Capability Name="runFullTrust" />
<Capability Name="internetClient" />
<rescap:Capability Name="broadFileSystemAccess" />
</Capabilities>
</Package>
EOF
echo "④ 打包 msix"
"$MAKEMSIX" pack -d "$OUT/root" -p "$OUT/Arcrun.msix" >/dev/null
SIZE=$(ls -lh "$OUT/Arcrun.msix" | awk '{print $5}')
echo "✅ 完成:$OUT/Arcrun.msix${SIZE},未簽章=送 Store 的正確狀態)"
echo
echo "🔬 送審前必做(否則會被退件):"
echo " · Identity 三值要與 Partner Center 完全一致(現在:${IDENTITY_NAME}"
echo " · broadFileSystemAccess 是受限能力,送審要寫明用途"
echo " (本 App 需要它才能讀使用者自選的任意資料夾)"