chore(release): 更新项目与 CLI 名称为 hose-use,升级到 v0.2.0,增加二进制构建与 GitHub Actions Release 工作流,集成 Agent Skill
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
🚀 Release / 🚀 Build & Publish Multi-Platform Binaries (push) Has been cancelled
This commit is contained in:
1 parent
b7a3bf2c03
commit
dbeb422aeb
13 files changed
+653
-37
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { mkdirSync } from "node:fs";
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const bun = process.env.BUN_BIN || "bun";
|
||||
|
||||
const TARGET_MAP = {
|
||||
"darwin-arm64": { bunTarget: "bun-darwin-arm64", outfile: "dist/bin/hose-use-darwin-arm64" },
|
||||
"darwin-x64": { bunTarget: "bun-darwin-x64", outfile: "dist/bin/hose-use-darwin-x64" },
|
||||
"linux-x64": { bunTarget: "bun-linux-x64", outfile: "dist/bin/hose-use-linux-x64" },
|
||||
"linux-arm64": { bunTarget: "bun-linux-arm64", outfile: "dist/bin/hose-use-linux-arm64" },
|
||||
"windows-x64": { bunTarget: "bun-windows-x64", outfile: "dist/bin/hose-use-windows-x64.exe" }
|
||||
};
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const isAll = args.includes("--all") || args.includes("--matrix");
|
||||
const targetArg = args.find((arg) => arg.startsWith("--target="))?.replace("--target=", "");
|
||||
|
||||
if (isAll) {
|
||||
for (const [name, config] of Object.entries(TARGET_MAP)) {
|
||||
buildTarget(name, config.bunTarget, resolve(root, config.outfile));
|
||||
}
|
||||
} else if (targetArg) {
|
||||
const config = TARGET_MAP[targetArg];
|
||||
if (!config) {
|
||||
throw new Error(`Unknown target: ${targetArg}. Available targets: ${Object.keys(TARGET_MAP).join(", ")}`);
|
||||
}
|
||||
buildTarget(targetArg, config.bunTarget, resolve(root, config.outfile));
|
||||
} else {
|
||||
const output = resolve(root, "dist/bin/hose-use");
|
||||
buildTarget("host", null, output);
|
||||
}
|
||||
|
||||
function buildTarget(name, bunTarget, output) {
|
||||
mkdirSync(dirname(output), { recursive: true });
|
||||
const buildArgs = ["build", "--compile"];
|
||||
if (bunTarget) {
|
||||
buildArgs.push(`--target=${bunTarget}`);
|
||||
}
|
||||
buildArgs.push("--outfile", output, "src/cli.ts");
|
||||
|
||||
console.log(`[build:binary] compiling target: ${name} -> ${output}`);
|
||||
run(bun, buildArgs);
|
||||
|
||||
if (process.platform === "darwin" && (name.startsWith("darwin") || name === "host")) {
|
||||
try {
|
||||
run("/usr/bin/codesign", ["--remove-signature", output], { quiet: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
try {
|
||||
run("/usr/bin/codesign", ["--force", "--sign", "-", output], { quiet: true });
|
||||
} catch {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run(command, args, options = {}) {
|
||||
const result = spawnSync(command, args, {
|
||||
cwd: root,
|
||||
stdio: options.quiet ? ["ignore", "ignore", "ignore"] : "inherit"
|
||||
});
|
||||
if (result.error) throw result.error;
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`${command} ${args.join(" ")} failed with status ${result.status}`);
|
||||
}
|
||||
}
|
||||
Executable
+169
@@ -0,0 +1,169 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
REPO="yunyingk/hose-serve-tool"
|
||||
|
||||
echo "==> Detecting platform and architecture..."
|
||||
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
|
||||
ARCH="$(uname -m)"
|
||||
|
||||
case "$OS" in
|
||||
darwin)
|
||||
PLATFORM="darwin"
|
||||
;;
|
||||
linux)
|
||||
PLATFORM="linux"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported operating system: $OS" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$ARCH" in
|
||||
x86_64|amd64)
|
||||
ARCH_NAME="x64"
|
||||
;;
|
||||
arm64|aarch64)
|
||||
ARCH_NAME="arm64"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported architecture: $ARCH" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Resolve best writable bin directory without requiring sudo
|
||||
TARGET_DIR=""
|
||||
for candidate in "/opt/homebrew/bin" "/usr/local/bin" "$HOME/.local/bin" "$HOME/bin"; do
|
||||
if [ -d "$candidate" ] && [ -w "$candidate" ]; then
|
||||
TARGET_DIR="$candidate"
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$TARGET_DIR" ]; then
|
||||
mkdir -p "$HOME/.local/bin"
|
||||
TARGET_DIR="$HOME/.local/bin"
|
||||
fi
|
||||
|
||||
ASSET_NAME="hose-use-${PLATFORM}-${ARCH_NAME}"
|
||||
TARGET_PATH="${TARGET_DIR}/hose-use"
|
||||
|
||||
get_file_size() {
|
||||
local file="$1"
|
||||
if [ ! -f "$file" ]; then
|
||||
echo "0"
|
||||
return
|
||||
fi
|
||||
local sz
|
||||
sz=$(stat -f%z "$file" 2>/dev/null || stat -c%s "$file" 2>/dev/null || wc -c < "$file" | tr -d ' ')
|
||||
echo "$sz"
|
||||
}
|
||||
|
||||
format_bytes() {
|
||||
local bytes="$1"
|
||||
if [ -z "$bytes" ] || [ "$bytes" -le 0 ]; then
|
||||
echo "0 B"
|
||||
return
|
||||
fi
|
||||
if [ "$bytes" -ge 1048576 ]; then
|
||||
awk "BEGIN {printf \"%.2f MB (%'d bytes)\", $bytes / 1048576, $bytes}" 2>/dev/null || awk "BEGIN {printf \"%.2f MB (%d bytes)\", $bytes / 1048576, $bytes}"
|
||||
elif [ "$bytes" -ge 1024 ]; then
|
||||
awk "BEGIN {printf \"%.2f KB (%d bytes)\", $bytes / 1024, $bytes}"
|
||||
else
|
||||
echo "${bytes} bytes"
|
||||
fi
|
||||
}
|
||||
|
||||
extract_host() {
|
||||
local url="$1"
|
||||
echo "$url" | sed -e 's|^[^/]*//||' -e 's|/.*$||'
|
||||
}
|
||||
|
||||
download_candidate() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
local label="$3"
|
||||
local host
|
||||
host="$(extract_host "$url")"
|
||||
|
||||
echo "==> Downloading from ${label}"
|
||||
echo " Source Host: ${host}"
|
||||
echo " Source URL: ${url}"
|
||||
|
||||
# Test connectivity & headers first
|
||||
if ! curl -fIs --connect-timeout 4 "$url" >/dev/null 2>&1; then
|
||||
echo " ↳ Source unreachable or asset not ready (404), falling back to next mirror..."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Download with progress bar
|
||||
if curl -fL --progress-bar "$url" -o "$dest"; then
|
||||
local size_bytes
|
||||
size_bytes="$(get_file_size "$dest")"
|
||||
if [ "$size_bytes" -gt 1000000 ]; then
|
||||
echo "✓ Download complete! Total size: $(format_bytes "$size_bytes")"
|
||||
echo "✓ Successfully fetched from host: ${host}"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
rm -f "$dest"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo "==> Target install location: ${TARGET_PATH}"
|
||||
TMP_FILE="$(mktemp)"
|
||||
DOWNLOAD_SUCCESS=false
|
||||
|
||||
# Candidate mirrors
|
||||
GITHUB_URL="https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
|
||||
GHPROXY_URL="https://ghfast.top/https://github.com/${REPO}/releases/latest/download/${ASSET_NAME}"
|
||||
|
||||
# 1. Try direct GitHub Releases
|
||||
if download_candidate "$GITHUB_URL" "$TMP_FILE" "GitHub Releases (Direct)"; then
|
||||
DOWNLOAD_SUCCESS=true
|
||||
fi
|
||||
|
||||
# 2. Try Fast CDN Proxy Fallback
|
||||
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
|
||||
if download_candidate "$GHPROXY_URL" "$TMP_FILE" "Fast CDN Mirror (Fallback)"; then
|
||||
DOWNLOAD_SUCCESS=true
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
|
||||
echo "Error: Failed to download ${ASSET_NAME} from all candidate mirrors." >&2
|
||||
rm -f "$TMP_FILE"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
chmod +x "$TMP_FILE"
|
||||
mv "$TMP_FILE" "$TARGET_PATH"
|
||||
|
||||
# Also create 'hose' symlink if possible
|
||||
if [ -w "$TARGET_DIR" ]; then
|
||||
ln -sf "$TARGET_PATH" "${TARGET_DIR}/hose" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Ad-hoc sign on macOS
|
||||
if [ "$PLATFORM" = "darwin" ] && command -v codesign >/dev/null 2>&1; then
|
||||
echo "==> Applying macOS code signature..."
|
||||
codesign --force --sign - "$TARGET_PATH" 2>/dev/null || true
|
||||
fi
|
||||
|
||||
echo "==> Initializing agent skill to ~/.agents/skills/hose-use..."
|
||||
"$TARGET_PATH" skill install >/dev/null 2>&1 || true
|
||||
echo "✓ Agent skill installed to ~/.agents/skills/hose-use"
|
||||
|
||||
echo ""
|
||||
echo "✨ hose-use successfully installed to ${TARGET_PATH}!"
|
||||
"$TARGET_PATH" version
|
||||
echo ""
|
||||
echo "Quick start:"
|
||||
echo " 1. Login: hose-use auth login --phone=177... --password=..."
|
||||
echo " 2. List corps: hose-use corps list"
|
||||
echo " 3. List workflows: hose-use workflow list"
|
||||
echo " 4. Switch mode: hose-use config mode stateless"
|
||||
echo ""
|
||||
Reference in new issue
Block a user