diff --git a/deploy/scripts/upload_assets.py b/deploy/scripts/upload_assets.py index 97fe7c2..1e8211e 100755 --- a/deploy/scripts/upload_assets.py +++ b/deploy/scripts/upload_assets.py @@ -32,13 +32,17 @@ ARTIFACT_SUFFIXES = ( ".rpm", ".pkg", "_win64.exe", + # 插件包。之前不在白名单里,会被静默跳过——而 release 本该带上它们, + # 否则用户要自己装 Go + hmapdev 逐插件构建(见 SDK 仓 scripts/build_plugin_bundles.sh)。 + ".hmap", + # 插件包汇总校验和(与 SHA256SUMS 同性质,独立文件免得混淆内核包与插件) + "SHA256SUMS.plugins", ) def is_artifact(name: str) -> bool: return name == "SHA256SUMS" or name.endswith(ARTIFACT_SUFFIXES) - def get_upload_url(tag: str, token: str, filename: str) -> tuple[str, dict]: q = urllib.parse.urlencode({"file_name": filename}) url = f"{API}/{REPO}/releases/{tag}/upload_url?{q}" diff --git a/internal/plugins/pluginmgr/bundle_install_test.go b/internal/plugins/pluginmgr/bundle_install_test.go index f731ab5..dd51c0c 100644 --- a/internal/plugins/pluginmgr/bundle_install_test.go +++ b/internal/plugins/pluginmgr/bundle_install_test.go @@ -23,9 +23,17 @@ func TestBuildPluginBundlesInstallable(t *testing.T) { if dir == "" { t.Skip("未设 HMAP_BUNDLE_DIR(指向 build_plugin_bundles.sh 的产出目录)") } + // 相对路径按**仓根**而非本包目录解析:测试的 cwd 是包目录, + // 而调用方通常写 `HMAP_BUNDLE_DIR=dist/plugins`(相对仓根),不修正就会 + // 报 “no such file or directory”,看起来像产物不存在。 + if !filepath.IsAbs(dir) { + if abs, err := filepath.Abs(filepath.Join(repoRoot(), dir)); err == nil { + dir = abs + } + } entries, err := os.ReadDir(dir) if err != nil { - t.Fatalf("读产物目录: %v", err) + t.Fatalf("读产物目录 %s: %v", dir, err) } n := 0 @@ -105,6 +113,25 @@ func TestBuildPluginBundlesInstallable(t *testing.T) { t.Logf("共 %d 个插件包通过内核解包校验", n) } +// repoRoot 从本文件位置向上找到仓根(含 go.mod 的目录)。 +func repoRoot() string { + d, err := os.Getwd() + if err != nil { + return "." + } + for i := 0; i < 8; i++ { + if _, err := os.Stat(filepath.Join(d, "go.mod")); err == nil { + return d + } + parent := filepath.Dir(d) + if parent == d { + break + } + d = parent + } + return "." +} + // extractField 从 JSON 文本里取一个字符串字段(本文件不想为此引 encoding/json)。 func extractField(js, key string) string { pat := `"` + key + `"`