Author SHA1 Message Date
cflmy 26bd87bfe9 ci: add protected component publish workflow and immutable release helpers
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
Vendor the root component-release helpers, add source packaging plus
release-evidence, and split publish (tag/manual) from notify (release event).
2026-11-27 19:23:08 +08:00
cflmy a3ddccd8a4 ci: run Web domain acceptance on the shared web image\n\nUse marqdo-ci-web (Ubuntu + Node/Playwright Chromium from the domestic\nnpmmirror binary mirror, released CLI/Bundle and packaged preview Tool). Pin the\nproduction app Playwright to the image version and use the full Chromium channel\nto avoid the unavailable headless-shell asset; no per-run browser download.
ci/woodpecker/pr/ci Pipeline was successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/manual/ci Pipeline was successful
2026-11-27 16:01:30 +08:00
cflmy b11cbeac57 ci: pin current Design/Preview lanes
Update child gitlinks to the commits that carry the shared CI image/release
notification lanes; domain behavior unchanged.
2026-11-27 15:25:48 +08:00
marqdo-ci 5b70e1d06e ci: notify the root reconcile on a completed release
Release event fast path: validate the secret is present, then ask the root
manual `reconcile` workflow to check the authoritative Gitea release. The call
is only a hint; correctness and lost-notification recovery stay in the root
reconcile cron/script.
2026-11-27 14:18:26 +08:00
cflmy 246ef7692c ci: pin Design/Preview unified CI image commits
Update the domain child gitlinks to the commits that consume the shared
marqdo-ci-rust image; the domain acceptance itself is unchanged and still runs
the packaged preview tool and production app on its own lane.
2026-11-27 14:10:51 +08:00
marqdo-norms 70ba4a27e5 docs: adopt ecosystem repository conventions and refresh active component facts
- Add the canonical AGENTS marker/link required by the root repository conventions.
- Correct the Web domain README/AGENTS status: Design/Preview are active with real
  entries, web-components remains planned; no fabricated progress.
- Pin the domain child gitlinks to their convention commits.

Refs cflmy/marqdo docs/REPOSITORY-CONVENTIONS.md
2026-11-27 11:37:07 +08:00
cflmy f6d0a9067c feat: activate the Web domain and its Design/Preview entries (WEB-05)
- web-design and web-preview move planned→active with their real scripts/ci.sh
  entries; web-components stays planned with no fabricated entry.
- The domain entry is scripts/domain-acceptance.sh: explicit CLI + built web
  Tool, three composition cases and the production delivery trial (API and
  browser E2E). Domain submodule gitlinks stay fixed to the merged Design
  (1b6607f) and Preview (eff273f) candidates.
- README/catalog/evidence record the activation and the remaining root
  integration steps (root gitlink, recursive check, web Tool cold install),
  which belong to the root candidate.

Refs cflmy/marqdo-ext-web#2, cflmy/marqdo#6
2026-11-27 09:04:18 +08:00
19 changed files with 961 additions and 30 deletions

No files matched your search

+1
View File
@@ -18,3 +18,4 @@
# 编辑器 # 编辑器
/.idea/ /.idea/
/.vscode/ /.vscode/
dist/
+14
View File
@@ -0,0 +1,14 @@
# Web domain acceptance: one published image with Node/Chromium, the released
# CLI/Bundle and the packaged preview Tool. The domain only runs its own
# acceptance entry; no Rust toolchain, browser download or CLI setup per run.
when:
event: [push, pull_request, manual]
steps:
domain:
image: git.cflmy.cn/cflmy/marqdo-ci-web:3.0.0-rc.5
environment:
PLAYWRIGHT_BROWSERS_PATH: /ms-playwright
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
commands:
- bash scripts/domain-acceptance.sh
+26
View File
@@ -0,0 +1,26 @@
when:
- event: [tag, manual]
steps:
publish:
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5
environment:
GITEA_PUBLISH_TOKEN:
from_secret: gitea_publish_token
COMPONENT_ID: web
REPOSITORY: cflmy/marqdo-ext-web
commands:
- |
set -eu
test -n "${GITEA_PUBLISH_TOKEN:?}"
test -n "${CI_COMMIT_TAG:?}"
export SOURCE_SHA="${CI_COMMIT_SHA}"
export VERSION="${CI_COMMIT_TAG#v}"
export COMPONENT_ID=web
export REPOSITORY=cflmy/marqdo-ext-web
sh scripts/package.sh
ARCHIVE="dist/marqdo-web-${VERSION}-source.tar.gz"
python3 scripts/release/publish_gitea.py \
--repo cflmy/marqdo-ext-web --tag "${CI_COMMIT_TAG}" --target "$SOURCE_SHA" --prerelease \
--body "Automated source release for web ${CI_COMMIT_TAG}." \
--asset "$ARCHIVE" --asset "${ARCHIVE}.sha256" --asset dist/release-evidence.json \
--evidence-out dist/gitea-publish-result.json
+12
View File
@@ -0,0 +1,12 @@
when:
event: [release]
steps:
notify:
image: git.cflmy.cn/cflmy/marqdo-ci-shell:3.0.0-rc.5
environment:
WOODPECKER_NOTIFY_TOKEN:
from_secret: woodpecker_notify_token
commands:
- |
set -eu
python3 scripts/release/notify_root.py --hint-component web --hint-tag "${CI_COMMIT_TAG:-}"
+7 -2
View File
@@ -1,5 +1,10 @@
# AGENTS.md — marqdo-ext-web 协作约定 # AGENTS.md — marqdo-ext-web 协作约定
<!-- marqdo:repo-conventions v1 -->
生态级仓库开发规范:https://git.cflmy.cn/cflmy/marqdo/src/branch/main/docs/REPOSITORY-CONVENTIONS.md
本文件约束在本仓库工作的 AI Agent 与开发者。**作者面规则以 [docs/WEB-DESIGN.md](docs/WEB-DESIGN.md) 为准,领域流程以 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) 为准**;本文件只写协作纪律,不复制合同正文。 本文件约束在本仓库工作的 AI Agent 与开发者。**作者面规则以 [docs/WEB-DESIGN.md](docs/WEB-DESIGN.md) 为准,领域流程以 [docs/DEVELOPMENT.md](docs/DEVELOPMENT.md) 为准**;本文件只写协作纪律,不复制合同正文。
## 1. 先读什么 ## 1. 先读什么
@@ -11,10 +16,10 @@
## 2. 事实边界(违反即返工) ## 2. 事实边界(违反即返工)
- 当前全体 Web 组件为 `planned`,Design 与 Preview 的子模块固定真实开发提交。功能入口、制品和 PASS 证据随实际实现建立。 - 领域与 **Design/Preview 已 active**(catalog 登记真实 `entry`,gitlink 固定已验收候选);`web-components` 仍 `planned`,不登记 entry。功能入口/制品/PASS 证据以各仓实际候选为准。
- 未实际运行的验收一律标 `UNVERIFIED`;`examples/research-workspace` 的六个文件尚未在真实 CLI/Design/Preview 上运行。 - 未实际运行的验收一律标 `UNVERIFIED`;`examples/research-workspace` 的六个文件尚未在真实 CLI/Design/Preview 上运行。
- 本仓库是聚合仓库:不实现 renderer/parser/数据库驱动,不复制子仓库源码,不把业务逻辑藏在“集成脚本”里。 - 本仓库是聚合仓库:不实现 renderer/parser/数据库驱动,不复制子仓库源码,不把业务逻辑藏在“集成脚本”里。
- 计划依赖(`requires`)须在晋升前以真实构建核实,`planned` gitlink 仅固定开发提交。 - 依赖(`requires`)已按真实构建核实;`planned` 子组件 gitlink 仅固定开发提交,不计完成率。
## 3. 修改规则 ## 3. 修改规则
+6 -6
View File
@@ -1,8 +1,8 @@
# marqdo-ext-web # marqdo-ext-web
Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作者合同、完整组合示例与跨组件验收,协调 Design/Preview 的变更与发布;**不承载生产实现**,也不是旧版 Markdown/GFM 页面渲染服务的继续。 Marqdo **Web 领域聚合仓库**(状态:`active`,WEB-05 已完成;Design/Preview active,web-components 仍 planned)。本仓固定 Web 作者合同、完整组合示例与跨组件验收,协调 Design/Preview 的变更与发布;**不承载生产实现**,也不是旧版 Markdown/GFM 页面渲染服务的继续。
本仓通过 Git 子模块固定 Design 和 Preview 的开发提交。领域和子组件均为 `planned`,实际验收入口和发行制品随功能开发建立。子组件登记见 [`components.toml`](components.toml)。 本仓通过 Git 子模块固定 Design 和 Preview 的开发提交。Design/Preview 已通过组件验收并激活;web-components 仍 planned。领域入口为 `scripts/domain-acceptance.sh`(根/领域 CI 以显式 CLI + 已构建 web Tool 运行)。子组件登记见 [`components.toml`](components.toml)。
## 唯一合同入口 ## 唯一合同入口
@@ -13,7 +13,7 @@ Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作
| [examples/research-workspace/](examples/research-workspace/) | 根规范 §8 科研工作台示例(六个 `.mq.md` 原样收录);入口 Analysis 已由 WEB-00 实测,Design/Preview 解释前整体仍 `UNVERIFIED` | | [examples/research-workspace/](examples/research-workspace/) | 根规范 §8 科研工作台示例(六个 `.mq.md` 原样收录);入口 Analysis 已由 WEB-00 实测,Design/Preview 解释前整体仍 `UNVERIFIED` |
| [tests/README.md](tests/README.md) | 领域/跨组件验收的目录、证据与当前状态 | | [tests/README.md](tests/README.md) | 领域/跨组件验收的目录、证据与当前状态 |
| [docs/evidence/WEB-00-analysis-probe.md](docs/evidence/WEB-00-analysis-probe.md) | WEB-00:真实 CLI Analysis 3 对合同依赖的探测证据(入口/链接/目标/负例,PASS) | | [docs/evidence/WEB-00-analysis-probe.md](docs/evidence/WEB-00-analysis-probe.md) | WEB-00:真实 CLI Analysis 3 对合同依赖的探测证据(入口/链接/目标/负例,PASS) |
| [components.toml](components.toml) | 直接子组件的治理记录(均为 planned,无 entry) | | [components.toml](components.toml) | 直接子组件的治理记录(Design/Preview active 并登记 entry,web-components planned) |
## 领域边界 ## 领域边界
@@ -29,11 +29,11 @@ Marqdo **Web 领域聚合仓库**(状态:`planned`)。本仓固定 Web 作
| ID | 目录 | kind | state | 职责 | requires | release | | ID | 目录 | kind | state | 职责 | requires | release |
| --- | --- | --- | --- | --- | --- | --- | | --- | --- | --- | --- | --- | --- | --- |
| `web-design` | `design/` | extension | planned | 设计文档解释、校验、组件图及交付 | `cli` | optional | | `web-design` | `design/` | extension | active | 设计文档解释、校验、组件图及交付 | `cli` | optional |
| `web-preview` | `preview/` | tool | planned | 通用原型渲染及 `web` 命令发行 | `cli`, `web-design` | optional | | `web-preview` | `preview/` | tool | active | 通用原型渲染及 `web` 命令发行 | `cli`, `web-design` | optional |
| `web-components` | `components/` | extension | planned | 可组合的设计文档与原型组件模板 | `web-design` | optional | | `web-components` | `components/` | extension | planned | 可组合的设计文档与原型组件模板 | `web-design` | optional |
- `planned` gitlink 固定已发布的开发提交。实现和验收通过后才登记实际 `entry` 并计入完成率。 - Design/Preview 已 active 并登记真实 `entry`;`planned` 子组件只固定开发提交,不计完成率,激活时补齐入口/测试/证据。
- 依赖为计划依赖;真实激活前须以实际 imports/构建输入/制品核实。 - 依赖为计划依赖;真实激活前须以实际 imports/构建输入/制品核实。
- Design 和 Preview 在各自的独立仓库开发。 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview) - Design 和 Preview 在各自的独立仓库开发。 [marqdo-web-design](https://git.cflmy.cn/cflmy/marqdo-web-design) · [marqdo-web-preview](https://git.cflmy.cn/cflmy/marqdo-web-preview)
- 本仓库不提供运行时入口,也不需要另一份 `tool.json`;唯一工具入口属于 Preview 的 `web` 命令。 - 本仓库不提供运行时入口,也不需要另一份 `tool.json`;唯一工具入口属于 Preview 的 `web` 命令。
+6 -3
View File
@@ -1,29 +1,32 @@
# 本仓只登记直接子组件(规范 §4.1)。Gitlink 是提交身份唯一权威, # 本仓只登记直接子组件(规范 §4.1)。Gitlink 是提交身份唯一权威,
# .gitmodules 是权威远端唯一记录;此处不重复 SHA、远端和语言包锁。 # .gitmodules 是权威远端唯一记录;此处不重复 SHA、远端和语言包锁。
# 当前三条均为 planned。Design/Preview 固定已推送的 WEB-01..03 候选提交;激活见 WEB-05。 # WEB-05:Design/Preview 通过组件验收并固定已合并提交,激活为 active 并登记真实入口;
# web-components 仍为 planned(无独立实现,不伪造入口)。
# 激活时同时更新 state/entry 并锁定已推送的精确 SHA(见 docs/DEVELOPMENT.md §3)。 # 激活时同时更新 state/entry 并锁定已推送的精确 SHA(见 docs/DEVELOPMENT.md §3)。
[[component]] [[component]]
id = "web-design" id = "web-design"
path = "design" path = "design"
kind = "extension" kind = "extension"
state = "planned" state = "active"
owner = "cflmy" owner = "cflmy"
scope = "设计文档解释、校验、组件图及交付" scope = "设计文档解释、校验、组件图及交付"
requires = ["cli"] requires = ["cli"]
checks_with = [] checks_with = []
release = "optional" release = "optional"
entry = "scripts/ci.sh"
[[component]] [[component]]
id = "web-preview" id = "web-preview"
path = "preview" path = "preview"
kind = "tool" kind = "tool"
state = "planned" state = "active"
owner = "cflmy" owner = "cflmy"
scope = "通用原型渲染及 web 命令发行" scope = "通用原型渲染及 web 命令发行"
requires = ["cli", "web-design"] requires = ["cli", "web-design"]
checks_with = [] checks_with = []
release = "optional" release = "optional"
entry = "scripts/ci.sh"
[[component]] [[component]]
id = "web-components" id = "web-components"
+1 -1
Submodule design updated: 1b6607fd3c...5c7e517121.
+29
View File
@@ -0,0 +1,29 @@
# WEB-05 Web 领域激活与根接入证据
日期:2026-11-27。责任仓:`marqdo-ext-web`(领域激活)+ 根 `marqdo`(gitlink/组合验收);工单:根 [marqdo#6](https://git.cflmy.cn/cflmy/marqdo/issues/6);上游 WEB-00..04 均已完成。
## 领域身份
| 对象 | 身份 |
| --- | --- |
| CLI | 根固定 `cli/deadf6e` 构建的 `marqdo 3.0.0-rc.4`,`sha256:6ede3b9e...` |
| Design(active) | `marqdo-web-design@1b6607fd3cc09801b4f6eacd2fba547caa0ec637`,入口 `scripts/ci.sh` |
| Preview(active) | `marqdo-web-preview@eff273f7f2f3919bab62eacded781c61d5f03f91`,入口 `scripts/ci.sh` |
| web-components | 保持 `planned`(无独立实现/入口,不伪造) |
| 领域入口 | `scripts/domain-acceptance.sh`(三案例 + 生产应用 API/浏览器 E2E) |
| 平台 | Linux x86_64;Node 24;Chromium headless shell |
## 已完成
- 领域 `components.toml`:Design/Preview 由 planned→active,登记真实 `entry`;web-components 保持 planned。
- 领域 `.gitmodules`/gitlink:固定已推送的 Design/Preview 合并提交;子组件 CI 入口真实存在。
- 领域验收入口 `scripts/domain-acceptance.sh`:显式 `MARQDO_BIN` + 已构建 web Tool,三案例 check/preview/handoff + 生产应用 API/浏览器 E2E;本地真实 PASS(见 WEB-04 证据)。
- WEB-00/01/02/03/04 证据已分别落在领域/组件仓。
## 根接入(由根候选完成)
- 根 catalog `web` 域 planned→active,登记 `entry = scripts/domain-acceptance.sh`;根 gitlink 固定本仓激活提交(一次切换,无旧路径)。
- `scripts/check-layout.py --checkouts` 递归校验领域与子组件固定提交、入口与工作树。
- 根集成候选:同一 CLI 构建/制品下运行领域入口、`web` Tool 冷安装(install → check/preview/handoff → remove,CLI 不变、无网络)与既有消费者门禁;同候选 SHA/制品摘要记录在根候选证据。
本文件是领域侧证据;根侧递归校验/冷安装/CI 结果记录在根 PR 与 #6 评论,不在此冒充。
+33 -15
View File
@@ -11,23 +11,23 @@
"express": "^4.21.2" "express": "^4.21.2"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.49.0" "@playwright/test": "1.49.0"
} }
}, },
"node_modules/@playwright/test": { "node_modules/@playwright/test": {
"version": "1.65.1", "version": "1.49.0",
"resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.65.1.tgz", "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.0.tgz",
"integrity": "sha512-y+NCIRm2LvY4slUVWvGh1nujJ8RF/hEisIsq2mtUPgdQC4L701bq5hZGMhrpeXjACvwvO9tj5dJqhvM6TP9lbw==", "integrity": "sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"playwright": "1.65.1" "playwright": "1.49.0"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=18"
} }
}, },
"node_modules/accepts": { "node_modules/accepts": {
@@ -335,6 +335,21 @@
"node": ">= 0.6" "node": ">= 0.6"
} }
}, },
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/function-bind": { "node_modules/function-bind": {
"version": "1.1.2", "version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
@@ -592,32 +607,35 @@
"license": "MIT" "license": "MIT"
}, },
"node_modules/playwright": { "node_modules/playwright": {
"version": "1.65.1", "version": "1.49.0",
"resolved": "https://registry.npmjs.org/playwright/-/playwright-1.65.1.tgz", "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.0.tgz",
"integrity": "sha512-vJ1FuoOrNwOKHUIVEvSt3jT1L+wjjDpwhwIstKtfvTh8XIG4FG4bIFuvNdMxi81LGfAhUgUZleVFaOLY4RIUUw==", "integrity": "sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"playwright-core": "1.65.1" "playwright-core": "1.49.0"
}, },
"bin": { "bin": {
"playwright": "cli.js" "playwright": "cli.js"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
} }
}, },
"node_modules/playwright-core": { "node_modules/playwright-core": {
"version": "1.65.1", "version": "1.49.0",
"resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.65.1.tgz", "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.0.tgz",
"integrity": "sha512-hqPpz7blSMPxWVdoeE1yiBSzXsKiVOd2k+kjCvmUywD2GPO2Dd9HfcWnq9NN0GHbNZDFgZ9JfBFr+X5/BLo0qw==", "integrity": "sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {
"playwright-core": "cli.js" "playwright-core": "cli.js"
}, },
"engines": { "engines": {
"node": ">=20" "node": ">=18"
} }
}, },
"node_modules/proxy-addr": { "node_modules/proxy-addr": {
+1 -1
View File
@@ -13,6 +13,6 @@
"express": "^4.21.2" "express": "^4.21.2"
}, },
"devDependencies": { "devDependencies": {
"@playwright/test": "^1.49.0" "@playwright/test": "1.49.0"
} }
} }
@@ -3,7 +3,7 @@ import { defineConfig } from "@playwright/test";
export default defineConfig({ export default defineConfig({
testDir: "./e2e", testDir: "./e2e",
timeout: 30_000, timeout: 30_000,
use: { baseURL: "http://127.0.0.1:4173" }, use: { baseURL: "http://127.0.0.1:4173", channel: "chromium" },
webServer: { webServer: {
command: "node server.js", command: "node server.js",
url: "http://127.0.0.1:4173", url: "http://127.0.0.1:4173",
+1 -1
Submodule preview updated: eff273f7f2...76cc20d9d8.
+49
View File
@@ -0,0 +1,49 @@
#!/bin/sh
# Deterministic source archive + release-evidence.json for this component.
#
# Required env:
# COMPONENT_ID catalog id (e.g. std-text)
# REPOSITORY owner/name (e.g. cflmy/marqdo-std-text)
# Optional:
# VERSION without leading v (default: derived from CI_COMMIT_TAG)
# SOURCE_SHA full commit (default: HEAD)
# OUT_DIR default dist
# DEPENDENCY repeatable write_evidence dependency specs via env DEP_ARGS
set -eu
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
COMPONENT_ID=${COMPONENT_ID:?COMPONENT_ID is required}
REPOSITORY=${REPOSITORY:?REPOSITORY is required}
SOURCE_SHA=${SOURCE_SHA:-$(git -C "$ROOT" rev-parse HEAD)}
OUT_DIR=${OUT_DIR:-dist}
TAG=${CI_COMMIT_TAG:-${TAG:-}}
if [ -n "${VERSION:-}" ]; then
:
elif [ -n "$TAG" ]; then
VERSION=${TAG#v}
else
echo "package.sh: set VERSION or CI_COMMIT_TAG" >&2
exit 1
fi
TAG=${TAG:-v$VERSION}
python3 "$ROOT/scripts/release/package_source.py" \
--root "$ROOT" \
--component-id "$COMPONENT_ID" \
--version "$VERSION" \
--out-dir "$OUT_DIR"
ARCHIVE=$(ls "$ROOT/$OUT_DIR"/marqdo-"$COMPONENT_ID"-"$VERSION"-source.tar.gz)
SHAFILE="$ARCHIVE.sha256"
EVIDENCE_ARGS="--component-id $COMPONENT_ID --repository $REPOSITORY --tag $TAG --source-sha $SOURCE_SHA --asset $ARCHIVE --asset $SHAFILE --out $ROOT/$OUT_DIR/release-evidence.json"
if [ -n "${CI_PIPELINE_NUMBER:-}" ]; then
EVIDENCE_ARGS="$EVIDENCE_ARGS --pipeline-number $CI_PIPELINE_NUMBER"
fi
if [ -n "${CI_PIPELINE_URL:-}" ]; then
EVIDENCE_ARGS="$EVIDENCE_ARGS --pipeline-url $CI_PIPELINE_URL"
fi
# shellcheck disable=SC2086
eval "python3 \"$ROOT/scripts/release/write_evidence.py\" $EVIDENCE_ARGS ${DEP_ARGS:-}"
echo "$ARCHIVE"
echo "$SHAFILE"
echo "$ROOT/$OUT_DIR/release-evidence.json"
+9
View File
@@ -0,0 +1,9 @@
# Vendored from marqdo scripts/component-release
#
# Do not edit in place across repositories. Change the root copy, re-test,
# then re-run install-vendor.sh and record the hashes below.
#
# package_source.py sha256=cb18c2f7fbe807f55d49e2cf77720f0d3e57d355177d2b127ac09e119f90c6ae
# write_evidence.py sha256=bb194bfd251e39308bc1dd53f46fd9efac181082ea43f668484b067d9e54acfc
# publish_gitea.py sha256=a21a84146d9ea826eb8d0632a18a991b0c39f17005d83bd988c92fc608f67523
# notify_root.py sha256=8eee83eb2bb31b99d93981f2a97fc2f0f9a486cc3c5c072f7dc12cfb63baf025
+103
View File
@@ -0,0 +1,103 @@
#!/usr/bin/env python3
"""Ask the root Marqdo reconcile workflow to scan after a release.
The payload is only a hint. Correctness comes from the root
`scripts/reconcile-releases.py` reading authoritative Gitea releases.
Lost notifications are recovered by the root `release-reconcile` cron.
"""
from __future__ import annotations
import argparse
import json
import os
import random
import sys
import time
import urllib.error
import urllib.request
DEFAULT_URL = "https://ci.cflmy.cn/api/repos/6/pipelines"
DEFAULT_BODY = {"branch": "main", "workflow": "reconcile"}
class NotifyError(Exception):
pass
def token() -> str:
value = (
os.environ.get("WOODPECKER_NOTIFY_TOKEN")
or os.environ.get("WOODPECKER_TOKEN")
or os.environ.get("woodpecker_token")
)
if not value:
raise NotifyError("WOODPECKER_NOTIFY_TOKEN (or WOODPECKER_TOKEN) is not set")
return value
def trigger(url: str, token_value: str, body: dict, attempts: int = 3) -> dict:
payload = json.dumps(body).encode()
last_error: Exception | None = None
for attempt in range(1, attempts + 1):
request = urllib.request.Request(
url,
data=payload,
method="POST",
headers={
"Authorization": f"Bearer {token_value}",
"Content-Type": "application/json",
"Accept": "application/json",
},
)
try:
with urllib.request.urlopen(request, timeout=60) as response:
raw = response.read()
decoded = json.loads(raw) if raw else {}
return {
"status": "triggered",
"http_status": response.status,
"pipeline_id": decoded.get("id"),
"pipeline_number": decoded.get("number"),
"attempt": attempt,
}
except urllib.error.HTTPError as error:
# Auth/permission failures must not retry forever.
if error.code in (401, 403, 404):
raise NotifyError(f"trigger rejected with HTTP {error.code}") from error
last_error = error
except urllib.error.URLError as error:
last_error = error
if attempt < attempts:
delay = (2 ** (attempt - 1)) + random.uniform(0, 0.5)
time.sleep(delay)
raise NotifyError(f"trigger failed after {attempts} attempts: {last_error}")
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--url", default=os.environ.get("MARQDO_RECONCILE_TRIGGER_URL", DEFAULT_URL))
parser.add_argument("--branch", default="main")
parser.add_argument("--workflow", default="reconcile")
parser.add_argument("--hint-component", default="")
parser.add_argument("--hint-tag", default="")
parser.add_argument("--attempts", type=int, default=3)
args = parser.parse_args(argv)
body = {"branch": args.branch, "workflow": args.workflow}
# Hints are informational only; the root reconcile never trusts them as commands.
if args.hint_component or args.hint_tag:
body["variables"] = {
"MARQDO_RELEASE_HINT_COMPONENT": args.hint_component,
"MARQDO_RELEASE_HINT_TAG": args.hint_tag,
}
try:
result = trigger(args.url, token(), body, attempts=max(1, args.attempts))
except NotifyError as error:
print(f"notify_root: FAIL: {error}", file=sys.stderr)
return 1
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+145
View File
@@ -0,0 +1,145 @@
#!/usr/bin/env python3
"""Build a deterministic source archive for a Marqdo component release.
Only allowlisted relative paths are included. The archive uses fixed mtime,
uid/gid, and sorted member names so the same tree always yields the same
sha256. Output is written under an isolated directory (default: dist/).
"""
from __future__ import annotations
import argparse
import hashlib
import io
import os
import sys
import tarfile
from pathlib import Path
DEFAULT_ALLOWLIST = (
"modules",
"index.mq.md",
"marqdo.yaml",
"LICENSE",
"README.md",
)
FIXED_MTIME = 0
EVIDENCE_NAME = "release-evidence.json"
class PackageError(Exception):
pass
def fail(message: str) -> None:
raise PackageError(message)
def is_safe_relative(path: str) -> bool:
if not path or path.startswith("/") or path.startswith("\\"):
return False
parts = Path(path).parts
return not any(part in (".", "..") for part in parts)
def collect_files(root: Path, allowlist: list[str]) -> list[tuple[str, Path]]:
selected: dict[str, Path] = {}
for entry in allowlist:
if not is_safe_relative(entry):
fail(f"unsafe allowlist entry: {entry!r}")
target = root / entry
if not target.exists():
continue
if target.is_file():
selected[entry.replace("\\", "/")] = target
continue
if not target.is_dir():
fail(f"allowlist entry is not a regular file or directory: {entry}")
for path in sorted(target.rglob("*")):
if not path.is_file():
continue
if path.is_symlink():
fail(f"symlinks are not publishable: {path.relative_to(root)}")
relative = path.relative_to(root).as_posix()
if not is_safe_relative(relative):
fail(f"unsafe relative path: {relative}")
selected[relative] = path
if not selected:
fail("allowlist matched no files")
return sorted(selected.items(), key=lambda item: item[0])
def archive_bytes(files: list[tuple[str, Path]]) -> bytes:
buffer = io.BytesIO()
with tarfile.open(fileobj=buffer, mode="w:gz", format=tarfile.PAX_FORMAT, compresslevel=9) as archive:
for relative, path in files:
data = path.read_bytes()
info = tarfile.TarInfo(name=relative)
info.size = len(data)
info.mtime = FIXED_MTIME
info.uid = 0
info.gid = 0
info.uname = ""
info.gname = ""
info.mode = 0o644
archive.addfile(info, io.BytesIO(data))
return buffer.getvalue()
def write_outputs(
root: Path,
out_dir: Path,
component_id: str,
version: str,
allowlist: list[str],
) -> dict:
files = collect_files(root, allowlist)
payload = archive_bytes(files)
digest = hashlib.sha256(payload).hexdigest()
out_dir.mkdir(parents=True, exist_ok=True)
archive_name = f"marqdo-{component_id}-{version}-source.tar.gz"
archive_path = out_dir / archive_name
sha_path = out_dir / f"{archive_name}.sha256"
archive_path.write_bytes(payload)
sha_path.write_text(f"{digest} {archive_name}\n", encoding="utf-8")
return {
"archive": str(archive_path),
"sha256_file": str(sha_path),
"name": archive_name,
"size": len(payload),
"sha256": digest,
"files": [relative for relative, _ in files],
}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--root", default=".", help="component repository root")
parser.add_argument("--component-id", required=True)
parser.add_argument("--version", required=True, help="version without leading v")
parser.add_argument("--out-dir", default="dist")
parser.add_argument(
"--allow",
action="append",
default=[],
help="relative allowlist entry (repeatable); defaults applied when omitted",
)
args = parser.parse_args(argv)
allowlist = args.allow or list(DEFAULT_ALLOWLIST)
root = Path(args.root).resolve()
out_dir = Path(args.out_dir)
if not out_dir.is_absolute():
out_dir = root / out_dir
try:
result = write_outputs(root, out_dir, args.component_id, args.version, allowlist)
except PackageError as error:
print(f"package_source: FAIL: {error}", file=sys.stderr)
return 1
print(result["archive"])
print(result["sha256_file"])
print(f"sha256={result['sha256']} size={result['size']} files={len(result['files'])}")
return 0
if __name__ == "__main__":
raise SystemExit(main())
+352
View File
@@ -0,0 +1,352 @@
#!/usr/bin/env python3
"""Publish a Gitea release with a draft transaction and immutable public assets.
Order (issue #10 §4.2):
create/reuse draft → upload non-index assets → upload release-evidence.json last
→ re-read and verify → mark non-draft → re-confirm.
Never deletes or replaces assets on an already-published (non-draft) release.
Identical published identity is treated as idempotent success.
"""
from __future__ import annotations
import argparse
import hashlib
import json
import mimetypes
import os
import sys
import urllib.error
import urllib.parse
import urllib.request
import uuid
from pathlib import Path
DEFAULT_API = "https://git.cflmy.cn/api/v1"
INDEX_NAME = "release-evidence.json"
class PublishError(Exception):
pass
def token() -> str:
value = (
os.environ.get("GITEA_PUBLISH_TOKEN")
or os.environ.get("GITEA_TOKEN")
or os.environ.get("gitea_token")
)
if not value:
raise PublishError("GITEA_PUBLISH_TOKEN (or GITEA_TOKEN) is not set")
return value
def request(
api: str,
method: str,
path: str,
token_value: str,
payload: dict | None = None,
raw: bytes | None = None,
content_type: str = "application/json",
) -> tuple[int, bytes]:
url = f"{api}{path}"
headers = {"Authorization": f"token {token_value}", "Accept": "application/json"}
data = None
if payload is not None:
data = json.dumps(payload).encode()
headers["Content-Type"] = content_type
elif raw is not None:
data = raw
headers["Content-Type"] = content_type
req = urllib.request.Request(url, data=data, headers=headers, method=method)
try:
with urllib.request.urlopen(req, timeout=120) as response:
return response.status, response.read()
except urllib.error.HTTPError as error:
return error.code, error.read()
def decode(body: bytes) -> object:
if not body:
return None
try:
return json.loads(body)
except Exception:
return None
def sha256_file(path: Path) -> str:
return hashlib.sha256(path.read_bytes()).hexdigest()
def get_release_by_tag(api: str, repo: str, tag: str, token_value: str) -> dict | None:
status, body = request(
api,
"GET",
f"/repos/{repo}/releases/tags/{urllib.parse.quote(tag, safe='')}",
token_value,
)
if status == 404:
return None
if status != 200:
raise PublishError(f"lookup release {tag} failed with HTTP {status}")
release = decode(body)
if not isinstance(release, dict) or "id" not in release:
raise PublishError("release lookup response malformed")
return release
def create_draft(
api: str,
repo: str,
tag: str,
body: str,
token_value: str,
*,
prerelease: bool,
target: str,
) -> dict:
payload = {
"tag_name": tag,
"name": tag,
"body": body,
"draft": True,
"prerelease": prerelease,
"target_commitish": target,
}
status, response = request(api, "POST", f"/repos/{repo}/releases", token_value, payload)
if status not in (200, 201):
raise PublishError(f"creating draft release failed with HTTP {status}: {response[:200]!r}")
release = decode(response)
if not isinstance(release, dict) or "id" not in release:
raise PublishError("draft create response malformed")
return release
def patch_release(api: str, repo: str, release_id: int, token_value: str, payload: dict) -> dict:
status, response = request(
api, "PATCH", f"/repos/{repo}/releases/{release_id}", token_value, payload
)
if status != 200:
raise PublishError(f"updating release {release_id} failed with HTTP {status}")
release = decode(response)
if not isinstance(release, dict):
raise PublishError("release patch response malformed")
return release
def list_assets(api: str, repo: str, release_id: int, token_value: str) -> list[dict]:
status, response = request(
api, "GET", f"/repos/{repo}/releases/{release_id}/assets", token_value
)
if status != 200:
raise PublishError(f"listing assets failed with HTTP {status}")
assets = decode(response)
if not isinstance(assets, list):
raise PublishError("asset list malformed")
return assets
def upload_asset(
api: str, repo: str, release_id: int, path: Path, token_value: str
) -> dict:
name = path.name
if not name or "/" in name or name in (".", ".."):
raise PublishError(f"unsafe asset name: {name!r}")
existing = list_assets(api, repo, release_id, token_value)
for asset in existing:
if asset.get("name") == name:
raise PublishError(
f"asset {name} already exists on draft/release {release_id}; "
"refusing to overwrite"
)
boundary = f"----marqdo{uuid.uuid4().hex}"
content_type = mimetypes.guess_type(name)[0] or "application/octet-stream"
body = bytearray()
body.extend(f"--{boundary}\r\n".encode())
body.extend(
f'Content-Disposition: form-data; name="attachment"; filename="{name}"\r\n'.encode()
)
body.extend(f"Content-Type: {content_type}\r\n\r\n".encode())
body.extend(path.read_bytes())
body.extend(f"\r\n--{boundary}--\r\n".encode())
status, response = request(
api,
"POST",
f"/repos/{repo}/releases/{release_id}/assets?name={urllib.parse.quote(name)}",
token_value,
raw=bytes(body),
content_type=f"multipart/form-data; boundary={boundary}",
)
if status not in (200, 201):
raise PublishError(f"uploading {name} failed with HTTP {status}: {response[:200]!r}")
result = decode(response)
if not isinstance(result, dict):
raise PublishError(f"upload response for {name} malformed")
return result
def asset_identity(path: Path) -> dict:
return {
"name": path.name,
"size": path.stat().st_size,
"sha256": sha256_file(path),
}
def published_matches(release: dict, expected: list[dict]) -> bool:
remote = {
asset.get("name"): int(asset.get("size") or -1)
for asset in (release.get("assets") or [])
}
if set(remote) != {item["name"] for item in expected}:
return False
for item in expected:
if remote.get(item["name"]) != item["size"]:
return False
return True
def publish(
*,
api: str,
repo: str,
tag: str,
body: str,
target: str,
assets: list[Path],
prerelease: bool,
token_value: str,
) -> dict:
if not assets:
raise PublishError("no assets to publish")
index_assets = [path for path in assets if path.name == INDEX_NAME]
other_assets = [path for path in assets if path.name != INDEX_NAME]
if len(index_assets) != 1:
raise PublishError("exactly one release-evidence.json is required")
ordered = other_assets + index_assets
expected = [asset_identity(path) for path in ordered]
existing = get_release_by_tag(api, repo, tag, token_value)
if existing and not existing.get("draft"):
if published_matches(existing, expected):
return {
"status": "idempotent",
"release_id": existing["id"],
"html_url": existing.get("html_url"),
"tag": tag,
"assets": expected,
}
raise PublishError(
f"published release {tag} already exists with different assets; "
"refusing to overwrite"
)
if existing and existing.get("draft"):
release = existing
# Keep draft body/target aligned when continuing an interrupted publish.
release = patch_release(
api,
repo,
int(release["id"]),
token_value,
{
"name": tag,
"body": body,
"draft": True,
"prerelease": prerelease,
"target_commitish": target,
},
)
else:
release = create_draft(
api, repo, tag, body, token_value, prerelease=prerelease, target=target
)
release_id = int(release["id"])
remote_names = {asset.get("name") for asset in list_assets(api, repo, release_id, token_value)}
for path in ordered:
if path.name in remote_names:
# Same-name asset already on this draft: require identical size, else fail.
match = next(
asset
for asset in list_assets(api, repo, release_id, token_value)
if asset.get("name") == path.name
)
if int(match.get("size") or -1) != path.stat().st_size:
raise PublishError(
f"draft asset {path.name} size mismatch; refusing to overwrite"
)
continue
upload_asset(api, repo, release_id, path, token_value)
refreshed = get_release_by_tag(api, repo, tag, token_value)
if not refreshed or not published_matches(refreshed, expected):
raise PublishError("post-upload release asset list does not match local files")
published = patch_release(
api,
repo,
release_id,
token_value,
{"draft": False, "prerelease": prerelease, "name": tag, "body": body},
)
if published.get("draft"):
raise PublishError("release remained draft after publish")
final = get_release_by_tag(api, repo, tag, token_value)
if not final or final.get("draft") or not published_matches(final, expected):
raise PublishError("final release confirmation failed")
return {
"status": "published",
"release_id": final["id"],
"html_url": final.get("html_url"),
"tag": tag,
"assets": expected,
}
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--api-url", default=os.environ.get("GITEA_API_URL", DEFAULT_API))
parser.add_argument("--repo", required=True, help="owner/name")
parser.add_argument("--tag", required=True)
parser.add_argument("--target", required=True, help="full commit SHA for the tag")
parser.add_argument("--body-file", default=None)
parser.add_argument("--body", default="")
parser.add_argument("--asset", action="append", default=[], required=True)
parser.add_argument("--prerelease", action="store_true", default=False)
parser.add_argument("--evidence-out", default="dist/gitea-publish-result.json")
args = parser.parse_args(argv)
body = args.body
if args.body_file:
body = Path(args.body_file).read_text(encoding="utf-8")
assets = [Path(item) for item in args.asset]
for path in assets:
if not path.is_file():
print(f"publish_gitea: FAIL: missing asset {path}", file=sys.stderr)
return 1
try:
result = publish(
api=args.api_url.rstrip("/"),
repo=args.repo,
tag=args.tag,
body=body,
target=args.target,
assets=assets,
prerelease=args.prerelease,
token_value=token(),
)
except PublishError as error:
print(f"publish_gitea: FAIL: {error}", file=sys.stderr)
return 1
out = Path(args.evidence_out)
out.parent.mkdir(parents=True, exist_ok=True)
out.write_text(json.dumps(result, indent=2, sort_keys=True) + "\n", encoding="utf-8")
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())
+165
View File
@@ -0,0 +1,165 @@
#!/usr/bin/env python3
"""Write the external release-evidence.json index for a component release.
The index references already-built assets. It never includes itself in
`assets[]` (no self-referential digest). Downstream discoverers hash the index
bytes separately when they download it.
"""
from __future__ import annotations
import argparse
import hashlib
import json
import re
import sys
from pathlib import Path
SHA_RE = re.compile(r"^[0-9a-f]{40}$")
DIGEST_RE = re.compile(r"^[0-9a-f]{64}$")
MAX_ASSETS = 128
MAX_DEPENDENCIES = 256
INDEX_NAME = "release-evidence.json"
class EvidenceError(Exception):
pass
def sha256_file(path: Path) -> str:
digest = hashlib.sha256()
with path.open("rb") as handle:
while True:
chunk = handle.read(1024 * 1024)
if not chunk:
break
digest.update(chunk)
return digest.hexdigest()
def parse_dependency(raw: str) -> dict:
# id=cli,source_sha=<40hex>[,asset_sha256=<64hex>]
fields = {}
for part in raw.split(","):
if "=" not in part:
raise EvidenceError(f"invalid dependency field: {raw!r}")
key, value = part.split("=", 1)
fields[key.strip()] = value.strip()
component_id = fields.get("id")
source_sha = fields.get("source_sha")
if not component_id or not source_sha or not SHA_RE.match(source_sha):
raise EvidenceError(f"dependency requires id and 40-hex source_sha: {raw!r}")
entry = {"id": component_id, "source_sha": source_sha}
asset = fields.get("asset_sha256")
if asset:
if not DIGEST_RE.match(asset):
raise EvidenceError(f"invalid asset_sha256 in dependency: {raw!r}")
entry["asset_sha256"] = asset
return entry
def build_evidence(
*,
component_id: str,
repository: str,
tag: str,
source_sha: str,
assets: list[Path],
dependencies: list[dict],
pipeline_number: int | None,
pipeline_url: str | None,
) -> dict:
if not component_id:
raise EvidenceError("component_id is required")
if "/" not in repository:
raise EvidenceError("repository must be owner/name")
if not tag:
raise EvidenceError("tag is required")
if not SHA_RE.match(source_sha):
raise EvidenceError("source_sha must be a 40-hex commit")
if not assets:
raise EvidenceError("at least one non-index asset is required")
if len(assets) > MAX_ASSETS:
raise EvidenceError(f"more than {MAX_ASSETS} assets")
if len(dependencies) > MAX_DEPENDENCIES:
raise EvidenceError(f"more than {MAX_DEPENDENCIES} dependencies")
asset_entries = []
seen_names: set[str] = set()
for path in assets:
if not path.is_file():
raise EvidenceError(f"asset missing: {path}")
name = path.name
if name == INDEX_NAME:
raise EvidenceError("assets must not include release-evidence.json itself")
if name in seen_names or "/" in name or name in (".", ".."):
raise EvidenceError(f"unsafe or duplicate asset name: {name!r}")
seen_names.add(name)
target = "source"
if name.endswith(".tar.gz") and "linux" in name:
target = "x86_64-unknown-linux-gnu"
asset_entries.append(
{
"name": name,
"target": target,
"size": path.stat().st_size,
"sha256": sha256_file(path),
}
)
evidence = {
"component_id": component_id,
"repository": repository,
"tag": tag,
"source_sha": source_sha,
"ci": {
"pipeline_number": pipeline_number,
"url": pipeline_url,
"source_sha": source_sha,
},
"assets": asset_entries,
"dependencies": dependencies,
}
return evidence
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--component-id", required=True)
parser.add_argument("--repository", required=True)
parser.add_argument("--tag", required=True)
parser.add_argument("--source-sha", required=True)
parser.add_argument("--asset", action="append", default=[], required=True)
parser.add_argument("--dependency", action="append", default=[])
parser.add_argument("--pipeline-number", type=int, default=None)
parser.add_argument("--pipeline-url", default=None)
parser.add_argument("--out", default=f"dist/{INDEX_NAME}")
args = parser.parse_args(argv)
try:
dependencies = [parse_dependency(item) for item in args.dependency]
evidence = build_evidence(
component_id=args.component_id,
repository=args.repository,
tag=args.tag,
source_sha=args.source_sha,
assets=[Path(item) for item in args.asset],
dependencies=dependencies,
pipeline_number=args.pipeline_number,
pipeline_url=args.pipeline_url,
)
except EvidenceError as error:
print(f"write_evidence: FAIL: {error}", file=sys.stderr)
return 1
out = Path(args.out)
out.parent.mkdir(parents=True, exist_ok=True)
payload = json.dumps(evidence, indent=2, sort_keys=True, ensure_ascii=False) + "\n"
if len(payload.encode()) > 1024 * 1024:
print("write_evidence: FAIL: index exceeds 1 MiB", file=sys.stderr)
return 1
out.write_text(payload, encoding="utf-8")
print(out)
return 0
if __name__ == "__main__":
raise SystemExit(main())