Compare commits
8 Commits
main
...
release/v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
243459eb2d | ||
|
|
38219e98ce | ||
|
|
28c19308c1 | ||
|
|
c6414d2a63 | ||
|
|
41cae90127 | ||
|
|
80452beb49 | ||
|
|
83437f950a | ||
|
|
1cd158b248 |
86
.github/workflows/deploy.yml
vendored
86
.github/workflows/deploy.yml
vendored
@ -68,29 +68,28 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
PACKAGE="${PLUGIN_NAME}@${VERSION}"
|
PACKAGE="${PLUGIN_NAME}@${VERSION}"
|
||||||
if npm view "${PACKAGE}" version >/dev/null 2>&1; then
|
ref="${GITHUB_REF_NAME:-release/v${VERSION}}"
|
||||||
PUBLISHED="$(npm view "${PACKAGE}" version)"
|
repo_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git"
|
||||||
echo "::notice::${PLUGIN_NAME}@${PUBLISHED} is available on npm"
|
echo "::notice::Installing ${PACKAGE} from source repo ${repo_url} ref ${ref}"
|
||||||
echo "source=npm" >> "$GITHUB_OUTPUT"
|
echo "source=source" >> "$GITHUB_OUTPUT"
|
||||||
echo "install_spec=${PACKAGE}" >> "$GITHUB_OUTPUT"
|
echo "install_ref=${ref}" >> "$GITHUB_OUTPUT"
|
||||||
else
|
echo "install_spec=${repo_url}" >> "$GITHUB_OUTPUT"
|
||||||
ref="${GITHUB_REF_NAME:-release/v${VERSION}}"
|
|
||||||
install_spec="git+${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}.git#${ref}"
|
|
||||||
echo "::warning::${PACKAGE} is not published to npm yet; installing from ${install_spec}"
|
|
||||||
echo "source=github" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "install_spec=${install_spec}" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Configure SSH key
|
- name: Configure SSH key
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.SINGLE_NODE_VPS_SSH_PRIVATE_KEY }}
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
if [ -z "${{ secrets.OPENCLAW_SSH_KEY }}" ]; then
|
if [ -z "${SSH_PRIVATE_KEY}" ]; then
|
||||||
echo "::error::Secret OPENCLAW_SSH_KEY is not set."
|
echo "::error::Secret SINGLE_NODE_VPS_SSH_PRIVATE_KEY is not set."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
install -m 700 -d ~/.ssh
|
install -m 700 -d ~/.ssh
|
||||||
printf '%s' "${{ secrets.OPENCLAW_SSH_KEY }}" > ~/.ssh/openclaw_ed25519
|
printf '%s\n' "${SSH_PRIVATE_KEY}" \
|
||||||
|
| perl -pe 's/\\n/\n/g; s/\r$//' \
|
||||||
|
> ~/.ssh/openclaw_ed25519
|
||||||
chmod 600 ~/.ssh/openclaw_ed25519
|
chmod 600 ~/.ssh/openclaw_ed25519
|
||||||
|
ssh-keygen -y -f ~/.ssh/openclaw_ed25519 >/dev/null
|
||||||
ssh-keyscan -H openclaw.svc.plus >> ~/.ssh/known_hosts 2>/dev/null || true
|
ssh-keyscan -H openclaw.svc.plus >> ~/.ssh/known_hosts 2>/dev/null || true
|
||||||
|
|
||||||
- name: Verify SSH connectivity
|
- name: Verify SSH connectivity
|
||||||
@ -103,29 +102,42 @@ jobs:
|
|||||||
VERSION: ${{ steps.version.outputs.value }}
|
VERSION: ${{ steps.version.outputs.value }}
|
||||||
INSTALL_SPEC: ${{ steps.install.outputs.install_spec }}
|
INSTALL_SPEC: ${{ steps.install.outputs.install_spec }}
|
||||||
INSTALL_SOURCE: ${{ steps.install.outputs.source }}
|
INSTALL_SOURCE: ${{ steps.install.outputs.source }}
|
||||||
|
INSTALL_REF: ${{ steps.install.outputs.install_ref }}
|
||||||
FORCE: ${{ inputs.force || 'false' }}
|
FORCE: ${{ inputs.force || 'false' }}
|
||||||
run: |
|
run: |
|
||||||
ssh -i ~/.ssh/openclaw_ed25519 -o BatchMode=yes -o ServerAliveInterval=30 \
|
ssh -i ~/.ssh/openclaw_ed25519 -o BatchMode=yes -o ServerAliveInterval=30 \
|
||||||
"${SSH_HOST}" bash -s -- "${PLUGIN_NAME}" "${VERSION}" "${INSTALL_SPEC}" "${INSTALL_SOURCE}" "${FORCE}" <<'REMOTE'
|
"${SSH_HOST}" bash -s -- "${PLUGIN_NAME}" "${VERSION}" "${INSTALL_SPEC}" "${INSTALL_SOURCE}" "${INSTALL_REF}" "${FORCE}" <<'REMOTE'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
PLUGIN_NAME="$1"
|
PLUGIN_NAME="$1"
|
||||||
VERSION="$2"
|
VERSION="$2"
|
||||||
INSTALL_SPEC="$3"
|
INSTALL_SPEC="$3"
|
||||||
INSTALL_SOURCE="$4"
|
INSTALL_SOURCE="$4"
|
||||||
FORCE="$5"
|
INSTALL_REF="$5"
|
||||||
|
FORCE="$6"
|
||||||
PACKAGE="${PLUGIN_NAME}@${VERSION}"
|
PACKAGE="${PLUGIN_NAME}@${VERSION}"
|
||||||
STATE_DIR="/tmp/openclaw-deploy"
|
STATE_DIR="/tmp/openclaw-deploy"
|
||||||
mkdir -p "${STATE_DIR}"
|
mkdir -p "${STATE_DIR}"
|
||||||
|
|
||||||
echo "==> Installing ${PACKAGE} from ${INSTALL_SOURCE} on $(hostname) (force=${FORCE})"
|
echo "==> Installing ${PACKAGE} from ${INSTALL_SOURCE} on $(hostname) (force=${FORCE})"
|
||||||
echo "==> Install spec: ${INSTALL_SPEC}"
|
echo "==> Install spec: ${INSTALL_SPEC}"
|
||||||
|
echo "==> Install ref: ${INSTALL_REF}"
|
||||||
|
|
||||||
|
get_installed_version() {
|
||||||
|
node -e '
|
||||||
|
const { execSync } = require("node:child_process");
|
||||||
|
const { join } = require("node:path");
|
||||||
|
const { existsSync, readFileSync } = require("node:fs");
|
||||||
|
const name = process.argv[1];
|
||||||
|
const root = execSync("npm root -g", { encoding: "utf8" }).trim();
|
||||||
|
const manifest = join(root, name, "package.json");
|
||||||
|
if (existsSync(manifest)) {
|
||||||
|
process.stdout.write(JSON.parse(readFileSync(manifest, "utf8")).version || "");
|
||||||
|
}
|
||||||
|
' "${PLUGIN_NAME}" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
# Record the previously installed version for rollback.
|
# Record the previously installed version for rollback.
|
||||||
PREVIOUS_VERSION=""
|
PREVIOUS_VERSION="$(get_installed_version)"
|
||||||
if command -v openclaw >/dev/null 2>&1; then
|
|
||||||
PREVIOUS_VERSION="$(npm ls -g "${PLUGIN_NAME}" --depth=0 2>/dev/null \
|
|
||||||
| awk -F'[@:]' '/'"${PLUGIN_NAME}"'@/ {print $2; exit}' || true)"
|
|
||||||
fi
|
|
||||||
echo "==> Previously installed version: ${PREVIOUS_VERSION:-<none>}"
|
echo "==> Previously installed version: ${PREVIOUS_VERSION:-<none>}"
|
||||||
|
|
||||||
# Skip when the requested version is already present unless forced.
|
# Skip when the requested version is already present unless forced.
|
||||||
@ -155,7 +167,32 @@ jobs:
|
|||||||
trap rollback ERR
|
trap rollback ERR
|
||||||
|
|
||||||
install_plugin() {
|
install_plugin() {
|
||||||
if command -v openclaw >/dev/null 2>&1; then
|
global_root="$(npm root -g)"
|
||||||
|
global_target="${global_root}/${PLUGIN_NAME}"
|
||||||
|
if [ -e "${global_target}" ] && [ ! -d "${global_target}" ]; then
|
||||||
|
echo "::remote-warning::Removing invalid global package path ${global_target}"
|
||||||
|
rm -f "${global_target}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${INSTALL_SOURCE}" = "source" ]; then
|
||||||
|
SOURCE_DIR="${STATE_DIR}/source/${PLUGIN_NAME}"
|
||||||
|
rm -rf "${SOURCE_DIR}"
|
||||||
|
mkdir -p "${SOURCE_DIR}"
|
||||||
|
git -C "${SOURCE_DIR}" init
|
||||||
|
git -C "${SOURCE_DIR}" remote add origin "${INSTALL_SPEC}"
|
||||||
|
git -C "${SOURCE_DIR}" fetch --depth 1 origin "${INSTALL_REF}"
|
||||||
|
git -C "${SOURCE_DIR}" checkout --detach FETCH_HEAD
|
||||||
|
TOOL_DIR="${STATE_DIR}/tools"
|
||||||
|
npm install --prefix "${TOOL_DIR}" pnpm@10.28.2
|
||||||
|
PNPM="${TOOL_DIR}/node_modules/.bin/pnpm"
|
||||||
|
"${PNPM}" --dir "${SOURCE_DIR}" install --frozen-lockfile
|
||||||
|
"${PNPM}" --dir "${SOURCE_DIR}" build
|
||||||
|
npm install -g "${SOURCE_DIR}"
|
||||||
|
elif [ "${INSTALL_SOURCE}" = "github" ]; then
|
||||||
|
global_root="$(npm root -g)"
|
||||||
|
global_target="${global_root}/${PLUGIN_NAME}"
|
||||||
|
npm install -g "${INSTALL_SPEC}"
|
||||||
|
elif command -v openclaw >/dev/null 2>&1; then
|
||||||
openclaw plugins install "${INSTALL_SPEC}" \
|
openclaw plugins install "${INSTALL_SPEC}" \
|
||||||
|| openclaw plugins update "${INSTALL_SPEC}" \
|
|| openclaw plugins update "${INSTALL_SPEC}" \
|
||||||
|| npm install -g "${INSTALL_SPEC}"
|
|| npm install -g "${INSTALL_SPEC}"
|
||||||
@ -171,8 +208,7 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Verify the installed version matches the requested version.
|
# Verify the installed version matches the requested version.
|
||||||
INSTALLED="$(npm ls -g "${PLUGIN_NAME}" --depth=0 2>/dev/null \
|
INSTALLED="$(get_installed_version)"
|
||||||
| awk -F'[@:]' '/'"${PLUGIN_NAME}"'@/ {print $2; exit}' || true)"
|
|
||||||
if [ "${INSTALLED}" != "${VERSION}" ]; then
|
if [ "${INSTALLED}" != "${VERSION}" ]; then
|
||||||
echo "::remote-error::Verification failed: expected ${VERSION}, found ${INSTALLED:-<none>}"
|
echo "::remote-error::Verification failed: expected ${VERSION}, found ${INSTALLED:-<none>}"
|
||||||
exit 1
|
exit 1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user