chore(guard): 发布脚本与 pre-push 都接插件两仓一致性检查
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
Verify (Gitea) / gate (build · unit · facts) (push) Failing after 49s
- scripts/release.sh、scripts/publish-update.sh:开头加前置门禁(不一致直接退出,不发包不传 NAS), 末尾加收尾复核(发布过程中若有人手改产物层,这里立刻暴露) - scripts/git-hooks/pre-push + scripts/install-git-hooks.sh + npm run hooks:install: 推送桌面仓前自动比对两仓,不一致拒绝推送;源仓不存在时跳过(CI/别人机器不阻塞) - docs/standards/plugin-source-of-truth.md §4 补「四道关卡」表与钩子安装方法
This commit is contained in:
1 parent
fd9575a96e
commit
43de3b0054
6 files changed
+55
-1
No files matched your search
@@ -52,6 +52,21 @@ node scripts/gen-market.js && node scripts/gen-market-page.js
|
||||
|
||||
## 4. 门禁与命令
|
||||
|
||||
三道关卡,从「本地提交」到「发布」都拦:
|
||||
|
||||
| 关卡 | 位置 | 触发 | 行为 |
|
||||
| --- | --- | --- | --- |
|
||||
| pre-push 钩子 | `.git/hooks/pre-push`(源文件在 `scripts/git-hooks/pre-push`) | `git push` 桌面仓 | 两仓不一致直接拒绝推送 |
|
||||
| 发布前置 | `scripts/release.sh` / `scripts/publish-update.sh` 开头 | 发版 | 不一致即退出,不发包、不传 NAS |
|
||||
| 发布收尾 | 同上脚本末尾 | 发版结束 | 再核一次,防止发布过程中有人手改产物 |
|
||||
| 市场前置 | `scripts/gen-market.js` 开头 | 发插件市场 | 不一致即中止 |
|
||||
|
||||
钩子安装(每台机器一次,clone 后执行):`npm run hooks:install`(等价 `bash scripts/install-git-hooks.sh`)。
|
||||
钩子里的检查在「源仓不存在」时会跳过,所以别人机器/CI 不会被卡。
|
||||
|
||||
---
|
||||
|
||||
|
||||
| 命令 | 作用 | 谁在用 |
|
||||
| --- | --- | --- |
|
||||
| `npm run validate`(源仓) | 源仓内部一致性:id/apiVersion/version 与 package.json 对齐 | 改插件的必跑 |
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
"test:facts": "node tests/architecture-facts-guard-test.js && node tests/release-records-test.js",
|
||||
"plugins:gc": "node scripts/plugins-publish.mjs --gc",
|
||||
"check:plugins": "node scripts/check-plugins-sync.js",
|
||||
"hooks:install": "bash scripts/install-git-hooks.sh",
|
||||
"coverage:browser": "npm run build && node scripts/coverage-browser.js",
|
||||
"audit:pins": "node scripts/audit-source-pins.js",
|
||||
"tokens:write": "node scripts/gen-tokens.js --write",
|
||||
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# pre-push:推送前校验桌面仓 plugins/ 与插件源仓一致(v3.26.109)
|
||||
# 由 scripts/install-git-hooks.sh 安装;源仓不存在时 check 脚本会自行跳过。
|
||||
root=$(git rev-parse --show-toplevel)
|
||||
if ! node "$root/scripts/check-plugins-sync.js"; then
|
||||
echo ''
|
||||
echo '[pre-push] 插件两仓不一致,已阻止推送。'
|
||||
echo '[pre-push] 正确做法:在 iwb-plugins-desktop 改源码 → 桌面仓 node scripts/sync-plugins-from-repo.js'
|
||||
echo '[pre-push] 说明:docs/standards/plugin-source-of-truth.md'
|
||||
exit 1
|
||||
fi
|
||||
exit 0
|
||||
Executable
+12
@@ -0,0 +1,12 @@
|
||||
#!/bin/sh
|
||||
# 安装仓库自带的 git hooks(目前只有 pre-push:插件两仓一致性)
|
||||
set -e
|
||||
root=$(cd "$(dirname "$0")/.." && pwd)
|
||||
hooks="$root/.git/hooks"
|
||||
[ -d "$hooks" ] || { echo "找不到 $hooks"; exit 1; }
|
||||
for f in "$root"/scripts/git-hooks/*; do
|
||||
name=$(basename "$f")
|
||||
cp "$f" "$hooks/$name"
|
||||
chmod +x "$hooks/$name"
|
||||
echo "installed .git/hooks/$name"
|
||||
done
|
||||
@@ -17,6 +17,10 @@
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# 插件两仓一致性(v3.26.109):桌面仓 plugins/ 必须等于插件源仓,否则发布的包/市场会和源码分叉。
|
||||
# 源仓不存在时脚本自身会跳过(CI / 别人机器不阻塞)。见 docs/standards/plugin-source-of-truth.md。
|
||||
node scripts/check-plugins-sync.js || { echo '✗ 插件两仓不一致,已停止发布(先同步插件源仓)'; exit 1; }
|
||||
|
||||
[ $# -ge 1 ] && node scripts/set-version.js "$1"
|
||||
V=$(node -e "console.log(require('./package.json').version)")
|
||||
KEY="${TAURI_SIGNING_PRIVATE_KEY:-$HOME/.config/iwb-updater.key}"
|
||||
@@ -133,3 +137,6 @@ fi
|
||||
|
||||
echo "== 完成:https://download.maqiart.eu.org/updates/latest.json"
|
||||
curl -s -m 15 https://download.maqiart.eu.org/updates/latest.json | head -c 200; echo
|
||||
|
||||
# 收尾再核一次:发布过程中若有人手改了产物层,这里会立刻暴露。
|
||||
node scripts/check-plugins-sync.js || { echo '⚠ 收尾校验失败:插件两仓已不一致,请按 docs/standards/plugin-source-of-truth.md 回写源仓'; exit 1; }
|
||||
+8
-1
@@ -3,6 +3,10 @@
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
# 插件两仓一致性(v3.26.109):桌面仓 plugins/ 必须等于插件源仓,否则发布的包/市场会和源码分叉。
|
||||
# 源仓不存在时脚本自身会跳过(CI / 别人机器不阻塞)。见 docs/standards/plugin-source-of-truth.md。
|
||||
node scripts/check-plugins-sync.js || { echo '✗ 插件两仓不一致,已停止发布(先同步插件源仓)'; exit 1; }
|
||||
|
||||
NAS_HOST="${NAS_HOST:-192.168.100.185}"
|
||||
NAS_USER="${NAS_USER:-malongan}"
|
||||
NAS_DIR="${NAS_DIR:-/vol8/web/iwb-download}"
|
||||
@@ -73,4 +77,7 @@ SIZE2=$(curl -s -o /dev/null -m 120 -w '%{size_download}' "$PKG_URL") || SIZE2=0
|
||||
PAGE_CODE=$(curl -s -o /dev/null -m 20 -w '%{http_code}' https://download.maqiart.eu.org/) || PAGE_CODE=000
|
||||
echo " 页面 $PAGE_CODE 包 $CODE 远端 $SIZE2 B / 本地 $SIZE B"
|
||||
if [ "$CODE" != "200" ] || [ "$SIZE2" != "$SIZE" ]; then echo "✗ 校验失败"; exit 1; fi
|
||||
echo "✓ 发布完成:https://download.maqiart.eu.org/"
|
||||
echo "✓ 发布完成:https://download.maqiart.eu.org/"
|
||||
|
||||
# 收尾再核一次:发布过程中若有人手改了产物层,这里会立刻暴露。
|
||||
node scripts/check-plugins-sync.js || { echo '⚠ 收尾校验失败:插件两仓已不一致,请按 docs/standards/plugin-source-of-truth.md 回写源仓'; exit 1; }
|
||||
Reference in new issue
Block a user