



















@@ -4,6 +4,9 @@ set -euo pipefail
4455mode="${1:-}"
66package_dir="${2:-}"
7+script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8+repo_root="$(cd "${script_dir}/.." && pwd)"
9+invocation_root="$(pwd)"
710811if [[ "${mode}" != "--dry-run" && "${mode}" != "--publish" ]]; then
912echo "usage: bash scripts/plugin-clawhub-publish.sh [--dry-run|--publish] <package-dir>" >&2
@@ -20,7 +23,9 @@ if [[ ! "${package_dir}" =~ ^extensions/[a-z0-9][a-z0-9._-]*$ ]]; then
2023exit 2
2124fi
222523-if [[ ! -f "${package_dir}/package.json" ]]; then
26+package_source="${invocation_root}/${package_dir}"
27+28+if [[ ! -f "${package_source}/package.json" ]]; then
2429echo "package.json not found under ${package_dir}" >&2
2530exit 2
2631fi
@@ -30,20 +35,13 @@ if ! command -v clawhub >/dev/null 2>&1; then
3035exit 1
3136fi
323733-script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
34-repo_root="$(cd "${script_dir}/.." && pwd)"
35-package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_dir}")"
36-package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_dir}")"
38+package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_source}")"
39+package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_source}")"
3740publish_tag="${PACKAGE_TAG:-latest}"
3841source_repo="${SOURCE_REPO:-${GITHUB_REPOSITORY:-openclaw/openclaw}}"
39-source_commit="${SOURCE_COMMIT:-$(git rev-parse HEAD)}"
40-source_ref="${SOURCE_REF:-$(git symbolic-ref -q HEAD || true)}"
41-clawhub_workdir="${CLAWDHUB_WORKDIR:-${CLAWHUB_WORKDIR:-$(pwd)}}"
42-package_source="${package_dir}"
43-44-if [[ "${package_source}" != /* && "${package_source}" != ./* ]]; then
45- package_source="./${package_source}"
46-fi
42+source_commit="${SOURCE_COMMIT:-$(git -C "${invocation_root}" rev-parse HEAD)}"
43+source_ref="${SOURCE_REF:-$(git -C "${invocation_root}" symbolic-ref -q HEAD || true)}"
44+clawhub_workdir="${CLAWDHUB_WORKDIR:-${CLAWHUB_WORKDIR:-${invocation_root}}}"
47454846pack_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-clawhub-pack.XXXXXX")"
4947cleanup() {
@@ -53,6 +51,8 @@ trap cleanup EXIT
53515452pack_cmd=(
5553 clawhub
54+ --workdir
55+"${clawhub_workdir}"
5656 package
5757 pack
5858"${package_source}"
@@ -121,6 +121,8 @@ fi
121121122122publish_cmd=(
123123 clawhub
124+ --workdir
125+"${clawhub_workdir}"
124126 package
125127 publish
126128"${pack_path}"
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。