Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11), free to diverge. Tree copied sans upstream .git; upstream remote added for future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19. Preserves docs/ARCHITECTURE.md. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
215 lines
5.8 KiB
Bash
215 lines
5.8 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
echo "usage: bash scripts/plugin-clawhub-publish.sh [--dry-run|--publish|--pack] <package-dir>"
|
|
}
|
|
|
|
if [[ "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
|
|
usage
|
|
exit 0
|
|
fi
|
|
|
|
mode="${1:-}"
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
repo_root="$(cd "${script_dir}/.." && pwd)"
|
|
invocation_root="$(pwd)"
|
|
|
|
if [[ "${mode}" != "--dry-run" && "${mode}" != "--publish" && "${mode}" != "--pack" ]]; then
|
|
usage >&2
|
|
exit 2
|
|
fi
|
|
shift
|
|
|
|
if [[ "${1:-}" == "--" ]]; then
|
|
shift
|
|
fi
|
|
package_dir=""
|
|
if [[ "$#" -gt 0 ]]; then
|
|
case "$1" in
|
|
-*) echo "unexpected plugin ClawHub package-dir option: $1" >&2; exit 2 ;;
|
|
*) package_dir="$1"; shift ;;
|
|
esac
|
|
fi
|
|
if [[ -z "${package_dir}" ]]; then
|
|
echo "missing package dir" >&2
|
|
exit 2
|
|
fi
|
|
if [[ "$#" -gt 0 ]]; then
|
|
echo "unexpected plugin ClawHub publish argument: $1" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if [[ ! "${package_dir}" =~ ^extensions/[a-z0-9][a-z0-9._-]*$ ]]; then
|
|
echo "invalid package dir: ${package_dir}" >&2
|
|
exit 2
|
|
fi
|
|
|
|
package_source="${invocation_root}/${package_dir}"
|
|
|
|
if [[ ! -f "${package_source}/package.json" ]]; then
|
|
echo "package.json not found under ${package_dir}" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! command -v clawhub >/dev/null 2>&1; then
|
|
echo "clawhub CLI is required on PATH" >&2
|
|
exit 1
|
|
fi
|
|
|
|
package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_source}")"
|
|
package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_source}")"
|
|
publish_tag="${PACKAGE_TAG:-latest}"
|
|
source_repo="${SOURCE_REPO:-${GITHUB_REPOSITORY:-openclaw/openclaw}}"
|
|
source_commit="${SOURCE_COMMIT:-$(git -C "${invocation_root}" rev-parse HEAD)}"
|
|
source_ref="${SOURCE_REF:-$(git -C "${invocation_root}" symbolic-ref -q HEAD || true)}"
|
|
clawhub_workdir="${CLAWDHUB_WORKDIR:-${CLAWHUB_WORKDIR:-${invocation_root}}}"
|
|
manual_override_reason="${OPENCLAW_CLAWHUB_MANUAL_OVERRIDE_REASON:-}"
|
|
|
|
pack_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-clawhub-pack.XXXXXX")"
|
|
cleanup() {
|
|
rm -rf "${pack_dir}"
|
|
}
|
|
trap cleanup EXIT
|
|
|
|
pack_cmd=(
|
|
clawhub
|
|
--workdir
|
|
"${clawhub_workdir}"
|
|
package
|
|
pack
|
|
"${package_source}"
|
|
--pack-destination
|
|
"${pack_dir}"
|
|
--json
|
|
)
|
|
|
|
build_package_runtime() {
|
|
if [[ "${OPENCLAW_PLUGIN_NPM_RUNTIME_BUILD:-1}" == "0" || "${OPENCLAW_PLUGIN_NPM_RUNTIME_BUILD:-1}" == "false" ]]; then
|
|
echo "Package-local runtime build: skipped"
|
|
return
|
|
fi
|
|
echo "Package-local runtime build: ${package_dir}"
|
|
node "${repo_root}/scripts/lib/plugin-npm-runtime-build.mjs" "${package_dir}" >&2
|
|
}
|
|
|
|
echo "Resolved package dir: ${package_dir}"
|
|
echo "Resolved package source: ${package_source}"
|
|
echo "Resolved package name: ${package_name}"
|
|
echo "Resolved package version: ${package_version}"
|
|
echo "Resolved publish tag: ${publish_tag}"
|
|
echo "Resolved source repo: ${source_repo}"
|
|
echo "Resolved source commit: ${source_commit}"
|
|
echo "Resolved source ref: ${source_ref:-<missing>}"
|
|
echo "Resolved ClawHub workdir: ${clawhub_workdir}"
|
|
echo "Publish auth: GitHub Actions OIDC via ClawHub short-lived token"
|
|
|
|
printf 'Pack command: CLAWHUB_WORKDIR=%q' "${clawhub_workdir}"
|
|
printf ' %q' "${pack_cmd[@]}"
|
|
printf '\n'
|
|
|
|
build_package_runtime
|
|
|
|
pack_json="${pack_dir}/pack.json"
|
|
CLAWHUB_WORKDIR="${clawhub_workdir}" \
|
|
node "${repo_root}/scripts/lib/plugin-npm-package-manifest.mjs" --run "${package_dir}" -- \
|
|
"${pack_cmd[@]}" > "${pack_json}"
|
|
pack_output="$(cat "${pack_json}")"
|
|
printf '%s\n' "${pack_output}"
|
|
|
|
pack_path="$(
|
|
PACK_OUTPUT="${pack_output}" node --input-type=module <<'EOF'
|
|
import { resolve } from "node:path";
|
|
|
|
const raw = process.env.PACK_OUTPUT ?? "";
|
|
let parsed;
|
|
try {
|
|
parsed = JSON.parse(raw);
|
|
} catch (error) {
|
|
console.error(`clawhub package pack did not return JSON: ${error instanceof Error ? error.message : String(error)}`);
|
|
process.exit(1);
|
|
}
|
|
if (!parsed || typeof parsed.path !== "string" || parsed.path.trim() === "") {
|
|
console.error("clawhub package pack output did not include a tarball path.");
|
|
process.exit(1);
|
|
}
|
|
console.log(resolve(parsed.path));
|
|
EOF
|
|
)"
|
|
|
|
if [[ ! -f "${pack_path}" ]]; then
|
|
echo "ClawPack tarball not found: ${pack_path}" >&2
|
|
exit 1
|
|
fi
|
|
|
|
echo "Resolved ClawPack: ${pack_path}"
|
|
|
|
if [[ "${mode}" == "--pack" ]]; then
|
|
output_dir="${OPENCLAW_CLAWHUB_PACK_OUTPUT_DIR:-}"
|
|
if [[ -z "${output_dir}" ]]; then
|
|
echo "OPENCLAW_CLAWHUB_PACK_OUTPUT_DIR is required for --pack" >&2
|
|
exit 2
|
|
fi
|
|
mkdir -p "${output_dir}"
|
|
output_path="${output_dir}/$(basename "${pack_path}")"
|
|
cp "${pack_path}" "${output_path}"
|
|
echo "Packed ClawPack: ${output_path}"
|
|
exit 0
|
|
fi
|
|
|
|
publish_cmd=(
|
|
clawhub
|
|
--workdir
|
|
"${clawhub_workdir}"
|
|
package
|
|
publish
|
|
"${pack_path}"
|
|
--tags
|
|
"${publish_tag}"
|
|
--source-repo
|
|
"${source_repo}"
|
|
--source-commit
|
|
"${source_commit}"
|
|
--source-path
|
|
"${package_dir}"
|
|
)
|
|
|
|
if [[ -n "${source_ref}" ]]; then
|
|
publish_cmd+=(
|
|
--source-ref
|
|
"${source_ref}"
|
|
)
|
|
fi
|
|
|
|
if [[ -n "${manual_override_reason}" ]]; then
|
|
publish_cmd+=(
|
|
--manual-override-reason
|
|
"${manual_override_reason}"
|
|
)
|
|
fi
|
|
|
|
printf 'Publish command: CLAWHUB_WORKDIR=%q' "${clawhub_workdir}"
|
|
printf ' %q' "${publish_cmd[@]}"
|
|
printf '\n'
|
|
|
|
if [[ "${mode}" == "--dry-run" ]]; then
|
|
CLAWHUB_WORKDIR="${clawhub_workdir}" "${publish_cmd[@]}" --dry-run
|
|
exit 0
|
|
fi
|
|
|
|
publish_log="${pack_dir}/publish.log"
|
|
for attempt in $(seq 1 "${OPENCLAW_CLAWHUB_PUBLISH_ATTEMPTS:-8}"); do
|
|
if CLAWHUB_WORKDIR="${clawhub_workdir}" "${publish_cmd[@]}" > >(tee "${publish_log}") 2>&1; then
|
|
exit 0
|
|
fi
|
|
if ! grep -Eqi "rate limit|too many requests|\\b429\\b" "${publish_log}"; then
|
|
exit 1
|
|
fi
|
|
echo "ClawHub publish hit a rate limit; retrying (${attempt}/${OPENCLAW_CLAWHUB_PUBLISH_ATTEMPTS:-8})." >&2
|
|
sleep "${OPENCLAW_CLAWHUB_PUBLISH_RETRY_DELAY_SECONDS:-60}"
|
|
done
|
|
|
|
echo "ClawHub publish failed after ${OPENCLAW_CLAWHUB_PUBLISH_ATTEMPTS:-8} attempts." >&2
|
|
exit 1
|