forked from cflmy/deepseek-harness
ci/woodpecker/push/ci Pipeline was canceled
The tag-only package lane cannot rely on an upstream git remote. Record the\ntested DSH baseline in packages/marqdo/harness/package.json and let the release\nmanifest/evidence fall back to it, so a clean clone still produces a complete\nmanifest. UPSTREAM.md documents the single record and update rule.
143 lines
5.9 KiB
Bash
Executable File
143 lines
5.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build one Marqdo Harness release archive and verify it from a cold extract.
|
|
#
|
|
# The archive is a portable prebuilt tree: the forked DSH source, production
|
|
# node_modules and built artifacts, an optional bundled Node runtime, the
|
|
# `mqdh` launcher and `install.sh`. It contains no Marqdo CLI/stdlib/ext/tool
|
|
# implementation; those are installed from trusted releases into MQDH_HOME.
|
|
# The release manifest, sidecar digest and optional signature are produced by
|
|
# scripts/release-manifest.ts so the archive itself stays content-only.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
root="$PWD"
|
|
out="${MARQDO_CI_OUT:-$root/.ci}"
|
|
mkdir -p "$out"
|
|
work_root="${MQDH_PACKAGE_WORK:-${TMPDIR:-/tmp}}"
|
|
mkdir -p "$work_root"
|
|
stage="$(mktemp -d "$work_root/mqdh-package.XXXXXX")"
|
|
verify="$(mktemp -d "$work_root/mqdh-cold.XXXXXX")"
|
|
trap 'rm -rf "$stage" "$verify"' EXIT
|
|
|
|
test -f apps/cli/lib/bin.js || { echo "build artifacts missing; run pnpm run build" >&2; exit 1; }
|
|
test -f apps/web/dist/index.html || { echo "web build missing; run pnpm run build" >&2; exit 1; }
|
|
|
|
version="$(sed -n 's/.*"version": *"\([^"]*\)".*/\1/p' packages/marqdo/harness/package.json | head -1)"
|
|
test -n "$version" || { echo "cannot read the product version" >&2; exit 1; }
|
|
target="x86_64-unknown-linux-gnu"
|
|
name="marqdo-harness-$version-$target"
|
|
app="$stage/$name"
|
|
mkdir -p "$app"
|
|
|
|
# Copy the prebuilt tree without VCS data or local scratch.
|
|
tar -C "$root" -cf - \
|
|
--exclude=.git --exclude=.ci --exclude=.integration-work --exclude=.issue-work \
|
|
--exclude=.app-verify --exclude=.dsh-build \
|
|
--exclude=node_modules/.cache --exclude='*.log' --exclude='*.tsbuildinfo' . | tar -C "$app" -xf -
|
|
|
|
git rev-parse HEAD > "$app/SOURCE_SHA"
|
|
|
|
if [ "${MQDH_BUNDLE_NODE:-1}" = "1" ]; then
|
|
mkdir -p "$app/runtime"
|
|
cp -L "$(command -v node)" "$app/runtime/node"
|
|
chmod 755 "$app/runtime/node"
|
|
"$app/runtime/node" --version > "$app/runtime/VERSION"
|
|
fi
|
|
|
|
cat > "$app/mqdh" <<'SH'
|
|
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
here="$(cd "$(dirname "$0")" && pwd)"
|
|
if [ -x "$here/runtime/node" ]; then
|
|
exec "$here/runtime/node" "$here/scripts/mqdh.mjs" "$@"
|
|
fi
|
|
exec node "$here/scripts/mqdh.mjs" "$@"
|
|
SH
|
|
chmod 755 "$app/mqdh"
|
|
cp scripts/install.sh "$app/install.sh"
|
|
chmod 755 "$app/install.sh"
|
|
|
|
archive="$out/$name.tar.gz"
|
|
tar -czf "$archive" -C "$stage" "$name"
|
|
sha256sum "$archive" | tee "$out/$name.tar.gz.sha256"
|
|
|
|
# Release identity: manifest, sidecar and optional Ed25519 signature.
|
|
manifest_args=(--archive "$archive" --target "$target" --out "$out")
|
|
if [ -n "${MQDH_RELEASE_PRIVATE_KEY:-}" ]; then
|
|
manifest_args+=(--private-key "$MQDH_RELEASE_PRIVATE_KEY" --public-key "${MQDH_RELEASE_PUBLIC_KEY:?MQDH_RELEASE_PUBLIC_KEY is required with a signing key}")
|
|
fi
|
|
node scripts/release-manifest.ts "${manifest_args[@]}"
|
|
|
|
# Cold install from the archive: clean prefix, clean home, no source checkout.
|
|
tar -xzf "$archive" -C "$verify"
|
|
cold="$verify/$name"
|
|
mkdir -p "$verify/prefix" "$verify/home"
|
|
MQDH_INSTALL_HARDLINK=1 "$cold/install.sh" --prefix "$verify/prefix" --no-path
|
|
installed_version="$("$verify/prefix/bin/mqdh" --version)"
|
|
case "$installed_version" in *"$version"*) ;; *) echo "cold version mismatch: $installed_version" >&2; exit 1 ;; esac
|
|
MQDH_HOME="$verify/home" "$verify/prefix/bin/mqdh" doctor --json > "$verify/doctor.json" || true
|
|
python3 - "$verify/doctor.json" <<'PY'
|
|
import json, sys
|
|
data = json.load(open(sys.argv[1]))
|
|
assert data["schema"] == "marqdo.mqdh.doctor", data
|
|
assert data["app"]["version"], data
|
|
assert data["platform"]["target"] == "x86_64-unknown-linux-gnu", data
|
|
PY
|
|
MQDH_HOME="$verify/home" "$verify/prefix/bin/mqdh" --dump-config > "$verify/dump.yml" 2> "$verify/dump.err"
|
|
grep -q 'mqdh-harness' "$verify/dump.yml"
|
|
grep -q 'mqdh-web' "$verify/dump.yml"
|
|
test -s "$verify/dump.yml"
|
|
|
|
python3 - "$out" "$archive" "$verify" "$installed_version" <<'PY'
|
|
import hashlib, json, os, pathlib, subprocess, sys
|
|
out, archive, verify, installed_version = pathlib.Path(sys.argv[1]), pathlib.Path(sys.argv[2]), pathlib.Path(sys.argv[3]), sys.argv[4]
|
|
def output(*args):
|
|
return subprocess.check_output(args, text=True).strip()
|
|
node_version = output('node', '--version')
|
|
cold_root = next(verify.glob('marqdo-harness-*'))
|
|
bundled_node = cold_root / 'runtime' / 'node'
|
|
bundled_version = output(str(bundled_node), '--version') if bundled_node.is_file() else None
|
|
bundled_sha = hashlib.sha256(bundled_node.read_bytes()).hexdigest() if bundled_node.is_file() else None
|
|
try:
|
|
upstream = output('git', 'rev-parse', 'upstream/master')
|
|
except Exception:
|
|
upstream = ''
|
|
if len(upstream) != 40:
|
|
upstream = os.environ.get('MQDH_DSH_UPSTREAM_SHA', '')
|
|
if len(upstream) != 40:
|
|
upstream = json.loads(pathlib.Path('packages/marqdo/harness/package.json').read_text()).get('dshUpstreamSha', '')
|
|
assert len(upstream) == 40, 'cannot determine the DSH upstream SHA'
|
|
record = {
|
|
'schema': 'marqdo.mqdh.package-evidence',
|
|
'schema_version': 1,
|
|
'status': 'PASS',
|
|
'archive': archive.name,
|
|
'size': archive.stat().st_size,
|
|
'sha256': hashlib.sha256(archive.read_bytes()).hexdigest(),
|
|
'application_sha': output('git', 'rev-parse', 'HEAD'),
|
|
'dsh_upstream_sha': upstream,
|
|
'platform': 'x86_64-unknown-linux-gnu',
|
|
'node': node_version,
|
|
'bundled_node': {'version': bundled_version, 'sha256': bundled_sha},
|
|
'cold_install': {
|
|
'version': installed_version,
|
|
'doctor_schema': json.loads((verify / 'doctor.json').read_text())['schema'],
|
|
'dump_config': 'PASS',
|
|
'bundle_node': 'PASS',
|
|
},
|
|
'manifest': (out / 'mqdh-release.json').name,
|
|
'signature': 'present' if (out / 'mqdh-release.json.sig').is_file() else 'unsigned',
|
|
'contains_marqdo_cli_source': False,
|
|
'unverified': [
|
|
'second clean host',
|
|
'macOS and Windows artifacts',
|
|
'official signing key',
|
|
'real model E2E',
|
|
],
|
|
}
|
|
(out / 'package-evidence.json').write_text(json.dumps(record, indent=2) + '\n')
|
|
print(json.dumps(record, indent=2))
|
|
PY
|
|
|
|
echo "mqdh package: PASS"
|