feat(update): 实现多镜像源自更新机制 (update/upgrade) 并升级版本至 v0.2.1
🚀 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
6e73de697b
commit
2dfcf67b00
12 files changed
+1021
-9
No files matched your search
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bun
|
||||
import { readFileSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { execSync } from "node:child_process";
|
||||
|
||||
const ROOT = join(import.meta.dirname, "..");
|
||||
const pkgPath = join(ROOT, "package.json");
|
||||
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
||||
const currentVersion: string = pkg.version;
|
||||
|
||||
const input = process.argv[2]?.trim();
|
||||
if (!input) {
|
||||
console.error("Usage: bun run bump <version | patch | minor | major>");
|
||||
console.error(`Current version: ${currentVersion}`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
let nextVersion = input.replace(/^v/, "");
|
||||
if (input === "patch" || input === "minor" || input === "major") {
|
||||
const [major, minor, patch] = currentVersion.split(".").map(Number);
|
||||
if (input === "patch") nextVersion = `${major}.${minor}.${patch + 1}`;
|
||||
if (input === "minor") nextVersion = `${major}.${minor + 1}.0`;
|
||||
if (input === "major") nextVersion = `${major + 1}.0.0`;
|
||||
}
|
||||
|
||||
if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?$/.test(nextVersion)) {
|
||||
console.error(`Invalid SemVer format: '${nextVersion}'`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log(`==> Bumping version: ${currentVersion} -> ${nextVersion}`);
|
||||
|
||||
// 1. package.json
|
||||
pkg.version = nextVersion;
|
||||
writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\n");
|
||||
console.log("✓ Updated package.json");
|
||||
|
||||
// 2. src/version.ts
|
||||
const versionTsPath = join(ROOT, "src", "version.ts");
|
||||
writeFileSync(versionTsPath, `export const VERSION = "${nextVersion}";\n`);
|
||||
console.log("✓ Updated src/version.ts");
|
||||
|
||||
// 3. README.md
|
||||
const readmePath = join(ROOT, "README.md");
|
||||
let readmeContent = readFileSync(readmePath, "utf-8");
|
||||
readmeContent = readmeContent.replace(/# hose-use \(v[\d.]+\)/g, `# hose-use (v${nextVersion})`);
|
||||
writeFileSync(readmePath, readmeContent);
|
||||
console.log("✓ Updated README.md");
|
||||
|
||||
// 4. skills/hose-use/SKILL.md
|
||||
const skillPath = join(ROOT, "skills", "hose-use", "SKILL.md");
|
||||
let skillContent = readFileSync(skillPath, "utf-8");
|
||||
skillContent = skillContent.replace(/# hose-use \(v[\d.]+\)/g, `# hose-use (v${nextVersion})`);
|
||||
writeFileSync(skillPath, skillContent);
|
||||
console.log("✓ Updated skills/hose-use/SKILL.md");
|
||||
|
||||
// 5. Sync to global ~/.agents/skills/hose-use/ if present
|
||||
const globalSkillDir = join(process.env.HOME || "", ".agents", "skills", "hose-use");
|
||||
const { existsSync, cpSync } = await import("node:fs");
|
||||
if (existsSync(globalSkillDir)) {
|
||||
cpSync(join(ROOT, "skills", "hose-use"), globalSkillDir, { recursive: true });
|
||||
console.log("✓ Synchronized ~/.agents/skills/hose-use/");
|
||||
}
|
||||
|
||||
console.log("\n🎉 Successfully bumped version to " + nextVersion + "!");
|
||||
console.log("\nNext steps to publish:");
|
||||
console.log(` 1. Update CHANGELOG.md (if exists)`);
|
||||
console.log(` 2. git commit -am "chore(release): bump version to v${nextVersion}"`);
|
||||
console.log(` 3. git tag -a v${nextVersion} -m "🚀 Release v${nextVersion}"`);
|
||||
console.log(` 4. git push origin main --tags\n`);
|
||||
+15
-4
@@ -118,15 +118,25 @@ TMP_FILE="$(mktemp)"
|
||||
DOWNLOAD_SUCCESS=false
|
||||
|
||||
# Candidate mirrors
|
||||
GITEA_URL="https://git.ying-qing.cn/gitea/hose-use/releases/download/latest/${ASSET_NAME}"
|
||||
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
|
||||
# 1. Try Gitea mirror
|
||||
if [ "${HOSE_USE_MIRROR:-auto}" = "gitea" ] || [ "${HOSE_USE_MIRROR:-auto}" = "auto" ]; then
|
||||
if download_candidate "$GITEA_URL" "$TMP_FILE" "Gitea High-Speed Mirror"; then
|
||||
DOWNLOAD_SUCCESS=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. Try Fast CDN Proxy Fallback
|
||||
# 2. Try direct GitHub Releases
|
||||
if [ "$DOWNLOAD_SUCCESS" = "false" ]; then
|
||||
if download_candidate "$GITHUB_URL" "$TMP_FILE" "GitHub Releases (Direct)"; then
|
||||
DOWNLOAD_SUCCESS=true
|
||||
fi
|
||||
fi
|
||||
|
||||
# 3. 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
|
||||
@@ -166,4 +176,5 @@ 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 " 5. Self-update: hose-use update"
|
||||
echo ""
|
||||
Reference in new issue
Block a user