mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(release): pin ClawHub publish workdir
This commit is contained in:
@@ -4,6 +4,9 @@ set -euo pipefail
|
|||||||
|
|
||||||
mode="${1:-}"
|
mode="${1:-}"
|
||||||
package_dir="${2:-}"
|
package_dir="${2:-}"
|
||||||
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
repo_root="$(cd "${script_dir}/.." && pwd)"
|
||||||
|
invocation_root="$(pwd)"
|
||||||
|
|
||||||
if [[ "${mode}" != "--dry-run" && "${mode}" != "--publish" ]]; then
|
if [[ "${mode}" != "--dry-run" && "${mode}" != "--publish" ]]; then
|
||||||
echo "usage: bash scripts/plugin-clawhub-publish.sh [--dry-run|--publish] <package-dir>" >&2
|
echo "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
|
|||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "${package_dir}/package.json" ]]; then
|
package_source="${invocation_root}/${package_dir}"
|
||||||
|
|
||||||
|
if [[ ! -f "${package_source}/package.json" ]]; then
|
||||||
echo "package.json not found under ${package_dir}" >&2
|
echo "package.json not found under ${package_dir}" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
@@ -30,20 +35,13 @@ if ! command -v clawhub >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_source}")"
|
||||||
repo_root="$(cd "${script_dir}/.." && pwd)"
|
package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_source}")"
|
||||||
package_name="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.name)' "${package_dir}")"
|
|
||||||
package_version="$(node -e 'const pkg = require(require("node:path").resolve(process.argv[1], "package.json")); console.log(pkg.version)' "${package_dir}")"
|
|
||||||
publish_tag="${PACKAGE_TAG:-latest}"
|
publish_tag="${PACKAGE_TAG:-latest}"
|
||||||
source_repo="${SOURCE_REPO:-${GITHUB_REPOSITORY:-openclaw/openclaw}}"
|
source_repo="${SOURCE_REPO:-${GITHUB_REPOSITORY:-openclaw/openclaw}}"
|
||||||
source_commit="${SOURCE_COMMIT:-$(git rev-parse HEAD)}"
|
source_commit="${SOURCE_COMMIT:-$(git -C "${invocation_root}" rev-parse HEAD)}"
|
||||||
source_ref="${SOURCE_REF:-$(git symbolic-ref -q HEAD || true)}"
|
source_ref="${SOURCE_REF:-$(git -C "${invocation_root}" symbolic-ref -q HEAD || true)}"
|
||||||
clawhub_workdir="${CLAWDHUB_WORKDIR:-${CLAWHUB_WORKDIR:-$(pwd)}}"
|
clawhub_workdir="${CLAWDHUB_WORKDIR:-${CLAWHUB_WORKDIR:-${invocation_root}}}"
|
||||||
package_source="${package_dir}"
|
|
||||||
|
|
||||||
if [[ "${package_source}" != /* && "${package_source}" != ./* ]]; then
|
|
||||||
package_source="./${package_source}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pack_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-clawhub-pack.XXXXXX")"
|
pack_dir="$(mktemp -d "${RUNNER_TEMP:-/tmp}/openclaw-clawhub-pack.XXXXXX")"
|
||||||
cleanup() {
|
cleanup() {
|
||||||
@@ -53,6 +51,8 @@ trap cleanup EXIT
|
|||||||
|
|
||||||
pack_cmd=(
|
pack_cmd=(
|
||||||
clawhub
|
clawhub
|
||||||
|
--workdir
|
||||||
|
"${clawhub_workdir}"
|
||||||
package
|
package
|
||||||
pack
|
pack
|
||||||
"${package_source}"
|
"${package_source}"
|
||||||
@@ -121,6 +121,8 @@ fi
|
|||||||
|
|
||||||
publish_cmd=(
|
publish_cmd=(
|
||||||
clawhub
|
clawhub
|
||||||
|
--workdir
|
||||||
|
"${clawhub_workdir}"
|
||||||
package
|
package
|
||||||
publish
|
publish
|
||||||
"${pack_path}"
|
"${pack_path}"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { execFileSync } from "node:child_process";
|
import { execFileSync } from "node:child_process";
|
||||||
import { chmodSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
import { chmodSync, mkdirSync, readFileSync, realpathSync, writeFileSync } from "node:fs";
|
||||||
import { delimiter, join } from "node:path";
|
import { delimiter, join } from "node:path";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterEach, describe, expect, it } from "vitest";
|
||||||
import {
|
import {
|
||||||
@@ -425,6 +425,9 @@ describe("plugin-clawhub-publish.sh", () => {
|
|||||||
`#!/usr/bin/env bash
|
`#!/usr/bin/env bash
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
printf '%s\\n' "$*" >> ${JSON.stringify(markerPath)}
|
printf '%s\\n' "$*" >> ${JSON.stringify(markerPath)}
|
||||||
|
if [[ "\${1:-}" == "--workdir" ]]; then
|
||||||
|
shift 2
|
||||||
|
fi
|
||||||
if [[ "\${1:-}" == "package" && "\${2:-}" == "pack" ]]; then
|
if [[ "\${1:-}" == "package" && "\${2:-}" == "pack" ]]; then
|
||||||
pack_destination=""
|
pack_destination=""
|
||||||
while [[ "$#" -gt 0 ]]; do
|
while [[ "$#" -gt 0 ]]; do
|
||||||
@@ -469,7 +472,11 @@ exit 0
|
|||||||
expect(output).toContain("Publish command: CLAWHUB_WORKDIR=");
|
expect(output).toContain("Publish command: CLAWHUB_WORKDIR=");
|
||||||
expect(output).toContain("Resolved ClawPack:");
|
expect(output).toContain("Resolved ClawPack:");
|
||||||
const invocations = readFileSync(markerPath, "utf8");
|
const invocations = readFileSync(markerPath, "utf8");
|
||||||
expect(invocations).toContain("package pack ./extensions/demo-plugin");
|
const resolvedRepoDir = realpathSync(repoDir);
|
||||||
|
expect(invocations).toContain(`--workdir ${resolvedRepoDir}`);
|
||||||
|
expect(invocations).toContain(
|
||||||
|
`package pack ${join(resolvedRepoDir, "extensions/demo-plugin")}`,
|
||||||
|
);
|
||||||
expect(invocations).toContain("package publish ");
|
expect(invocations).toContain("package publish ");
|
||||||
expect(invocations).toContain(".tgz --tags latest");
|
expect(invocations).toContain(".tgz --tags latest");
|
||||||
expect(invocations).toContain("--dry-run");
|
expect(invocations).toContain("--dry-run");
|
||||||
|
|||||||
Reference in New Issue
Block a user