Files
marqdo-view/scripts/package.sh
T
Marqdo View 340ecb035f
ci/woodpecker/push/woodpecker Pipeline was successful
feat: migrate View 0.3.0 to marqdo 3.0.0-rc.4 contracts
Replace the retired rc.2 Analysis v2/Trace v2/Execution Events v1 stack with the
single current contract family:

- Analysis v3 (ADR-0069 public boundary): one check --emit artifact carries the
  exact source, Markdown AST, heading scopes (heading_span + complete span),
  anchors, state-bearing references, calls, resources and diagnostics; the old
  revision-3 shape is rejected with a rebuild hint.
- Observation v1: one run/call --output jsonl stream (+ atomic
  --observation-file snapshot) decoded by one decoder and projected into the
  reader/SSE/export layers; stale/malformed/truncated/incomplete never render
  as success.
- CLI Tool revision 1: requires {api_revision:1, analysis:3, observation:1},
  product range >=3.0.0-rc.3,<4.0.0, only MARQDO_BIN and
  MARQDO_API_REVISION are consumed.
- Remove compatibility branches, retired flags/env vars and duplicate decoders;
  re-record Analysis v3 and Observation v1 fixtures; rewrite contract,
  integration and security tests (173 passing locally).
- Add check-no-legacy/check-docs/check-observation gates, rc.4 pins in the
  CI pipelines, 0.3.0 Tool bundle and evidence manifest support.

See issues #4, #5 and #6; acceptance baseline is CLI source
452e9a32bd9e40dba427d4180691c58bab74449e, archive
9c3f166b5e5b8840d39d10019074e4e1c42432fc23e26c69670e64fdcf4e15d8.
2026-11-25 22:12:51 +08:00

131 lines
4.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Build and assemble the CLI Tool revision 1 release bundle for marqdo-view 0.3.0.
#
# Produces:
# dist/marqdo-view/ stable bundle path
# dist/marqdo-view-<version>-<target>.tar.gz (+ .sha256)
#
# The bundle contains only the runtime binary, the manifest and the legal /
# release-note files. CSS/JS/images are compiled into the binary (ADR-0002),
# so there is exactly one asset source for Live and Export.
#
# The current public contracts are exact: api_revision 1, Analysis 3 and
# Observation 1. There is no version negotiation and no `compatibility` field.
set -euo pipefail
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$repo_root"
: "${CARGO:=cargo}"
: "${MARQDO_BIN:=}"
version="$("$CARGO" metadata --no-deps --format-version 1 \
| python3 -c 'import json,sys; print(json.load(sys.stdin)["packages"][0]["version"])')"
target="$("$CARGO" -vV 2>/dev/null | sed -n 's/^host: //p')"
target="${target:-x86_64-unknown-linux-gnu}"
echo "==> cargo build --release --locked"
"$CARGO" build --release --locked
dist="$repo_root/dist"
bundle="$dist/marqdo-view"
rm -rf "$bundle"
mkdir -p "$bundle/bin"
binary="$repo_root/target/release/marqdo-view"
if [[ ! -x "$binary" ]]; then
echo "error: missing release binary $binary" >&2
exit 1
fi
cp "$binary" "$bundle/bin/marqdo-view"
chmod 755 "$bundle/bin/marqdo-view"
cp tool.json "$bundle/tool.json"
cp README.md COMPATIBILITY.md CHANGELOG.md LICENSE-MIT LICENSE-APACHE "$bundle/"
# Verify the tool manifest and the binary agree on the version.
manifest_version="$(python3 -c 'import json;print(json.load(open("tool.json"))["version"])')"
if [[ "$manifest_version" != "$version" ]]; then
echo "error: tool.json version $manifest_version != package version $version" >&2
exit 1
fi
binary_version="$("$bundle/bin/marqdo-view" --version | awk '{print $2}')"
if [[ "$binary_version" != "$version" ]]; then
echo "error: binary prints version $binary_version, package is $version" >&2
exit 1
fi
source_sha="unknown"
if git rev-parse --verify HEAD >/dev/null 2>&1; then
source_sha="$(git rev-parse HEAD)"
fi
printf '%s\n' "$source_sha" > "$bundle/SOURCE_SHA"
python3 - "$bundle" "$version" "$target" "$source_sha" <<'PY'
import hashlib
import json
import pathlib
import sys
bundle = pathlib.Path(sys.argv[1])
version, target, source_sha = sys.argv[2], sys.argv[3], sys.argv[4]
tool = json.loads((bundle / 'tool.json').read_text())
requires = tool.get('requires') or {}
if 'compatibility' in tool:
raise SystemExit('tool.json must not contain a compatibility field')
if requires != {'api_revision': 1, 'analysis': 3, 'observation': 1}:
raise SystemExit('tool.json requires must be exactly api_revision 1 / analysis 3 / observation 1')
files = []
for path in sorted(bundle.rglob('*')):
if not path.is_file():
continue
rel = path.relative_to(bundle).as_posix()
if rel in ('RELEASE_INFO.json', 'SHA256SUMS'):
continue
data = path.read_bytes()
files.append({
'path': rel,
'size': len(data),
'sha256': hashlib.sha256(data).hexdigest(),
})
info = {
'schema': 'marqdo.view-release-info',
'schema_version': 1,
'tool_name': 'marqdo-view',
'tool_version': version,
'command': 'view',
'target': target,
'source_sha': source_sha,
'requires': {
'api_revision': 1,
'analysis': 3,
'observation': 1,
},
'release': {
'product_range': '>=3.0.0-rc.3,<4.0.0',
'markdown_profile': 'marqdo.md.v1',
'platform': 'linux-x86_64-glibc2.39',
},
'files': files,
}
(bundle / 'RELEASE_INFO.json').write_text(json.dumps(info, indent=2, sort_keys=True) + '\n')
with (bundle / 'SHA256SUMS').open('w') as out:
for entry in files:
out.write(f"{entry['sha256']} {entry['path']}\n")
PY
# Deterministic archive: sorted paths, fixed owner, gzip without timestamps.
archive="marqdo-view-${version}-${target}.tar.gz"
tar --sort=name --owner=0 --group=0 --numeric-owner --mtime='UTC 2026-01-01' \
-C "$dist" -cf - marqdo-view | gzip -n > "$dist/$archive"
( cd "$dist" && sha256sum "$archive" > "$archive.sha256" )
if [[ -n "$MARQDO_BIN" ]]; then
echo "==> smoke install against frozen core"
MARQDO_BIN="$MARQDO_BIN" "$repo_root/scripts/install-smoke.sh" "$bundle/tool.json"
fi
echo "bundle: $bundle"
echo "archive: $dist/$archive"
echo "sha256: $(cut -d' ' -f1 "$dist/$archive.sha256")"