From afa36ef45a5c1254a73ba335dc3e381baca26463 Mon Sep 17 00:00:00 2001 From: PerfectPan Date: Mon, 4 May 2026 23:56:50 +0800 Subject: [PATCH 1/2] fix: pin installer release version --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 2 +- docs/release.md | 14 ++++++++++---- install.sh | 12 ++++++++++-- scripts/check-release-prep.sh | 3 +++ site/src/routes/index.tsx | 4 ++-- 7 files changed, 28 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 840baf2..2025b10 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -684,7 +684,7 @@ dependencies = [ [[package]] name = "ocvm" -version = "0.1.0" +version = "0.1.1" dependencies = [ "anyhow", "assert_cmd", diff --git a/Cargo.toml b/Cargo.toml index e7b4a5e..49d7019 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ocvm" -version = "0.1.0" +version = "0.1.1" edition = "2021" description = "OpenClaw Version Manager" license = "MIT" diff --git a/README.md b/README.md index b85ec78..912a52a 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ Rollback does not delete unrelated installed versions. After a GitHub Release exists: ```bash -curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/main/install.sh | sh +curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/v0.1.1/install.sh | sh ``` ## Docker E2E diff --git a/docs/release.md b/docs/release.md index 6de8a72..0d48bfb 100644 --- a/docs/release.md +++ b/docs/release.md @@ -17,18 +17,24 @@ cargo package --allow-dirty 3. Create and push a version tag: ```bash -git tag v0.1.0 -git push origin v0.1.0 +git tag v0.1.1 +git push origin v0.1.1 ``` The `Release` workflow builds platform binaries, packages archives, generates SHA256 checksum files, and creates a GitHub Release. ## Install Script -Users can install the latest release with: +Users can install a specific release with: ```bash -curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/main/install.sh | sh +curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/v0.1.1/install.sh | sh +``` + +Override `OCVM_VERSION` to install a different release: + +```bash +curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/v0.1.1/install.sh | OCVM_VERSION=latest sh ``` ## Docker E2E diff --git a/install.sh b/install.sh index 12617ef..49d4e12 100755 --- a/install.sh +++ b/install.sh @@ -4,6 +4,8 @@ set -eu REPO="${OCVM_REPO:-PerfectPan/ocvm}" INSTALL_DIR="${OCVM_INSTALL_DIR:-$HOME/.local/bin}" API_BASE="${GITHUB_API_URL:-https://api.github.com}" +INSTALLER_VERSION="v0.1.1" +VERSION="${OCVM_VERSION:-$INSTALLER_VERSION}" need() { command -v "$1" >/dev/null 2>&1 || { @@ -40,12 +42,19 @@ esac target="${arch}-${os}" asset="ocvm-${target}.tar.gz" +if [ "$VERSION" = "latest" ]; then + api_url="${API_BASE}/repos/${REPO}/releases/latest" +else + api_url="${API_BASE}/repos/${REPO}/releases/tags/${VERSION}" +fi + if [ "${OCVM_INSTALL_DRY_RUN:-}" = "1" ]; then cat <

Install

-

One command once the first GitHub Release is published.

+

Install a pinned release with one command.

-          curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/main/install.sh | sh
+          curl -fsSL https://raw.githubusercontent.com/PerfectPan/ocvm/v0.1.1/install.sh | sh
         
From 46923d2f26e9aaf3e213267835000c3f5a2f47fc Mon Sep 17 00:00:00 2001 From: PerfectPan Date: Tue, 5 May 2026 00:16:32 +0800 Subject: [PATCH 2/2] test: close fake openclaw before execution --- tests/cli.rs | 26 +++++++++++++++++--------- tests/core.rs | 25 +++++++++++++++++-------- 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/tests/cli.rs b/tests/cli.rs index 230c336..5d3fafe 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -1,6 +1,6 @@ use assert_cmd::Command; use predicates::prelude::*; -use std::{fs, path::PathBuf}; +use std::{fs, io::Write, path::PathBuf}; use tempfile::TempDir; fn cmd(home: &TempDir) -> Command { @@ -26,6 +26,21 @@ fn fake_openclaw_body(output: &str) -> String { } } +fn write_fake_openclaw(path: &PathBuf, output: &str) { + let mut file = fs::File::create(path).unwrap(); + file.write_all(fake_openclaw_body(output).as_bytes()) + .unwrap(); + file.sync_all().unwrap(); + drop(file); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let mut permissions = fs::metadata(path).unwrap().permissions(); + permissions.set_mode(0o755); + fs::set_permissions(path, permissions).unwrap(); + } +} + fn install_fake(home: &TempDir, version: &str, output: &str) { let bin = home .path() @@ -36,14 +51,7 @@ fn install_fake(home: &TempDir, version: &str, output: &str) { .join(".bin"); fs::create_dir_all(&bin).unwrap(); let openclaw = fake_openclaw_path(bin); - fs::write(&openclaw, fake_openclaw_body(output)).unwrap(); - #[cfg(unix)] - { - use std::os::unix::fs::PermissionsExt; - let mut permissions = fs::metadata(&openclaw).unwrap().permissions(); - permissions.set_mode(0o755); - fs::set_permissions(openclaw, permissions).unwrap(); - } + write_fake_openclaw(&openclaw, output); } #[test] diff --git a/tests/core.rs b/tests/core.rs index 5421281..62ca484 100644 --- a/tests/core.rs +++ b/tests/core.rs @@ -6,6 +6,7 @@ use ocvm::source::{RemoteVersion, SourceProvider}; use ocvm::version; use std::cell::RefCell; use std::fs; +use std::io::Write; use std::path::{Path, PathBuf}; use tempfile::TempDir; @@ -62,6 +63,21 @@ fn fake_openclaw_body(output: &str) -> String { } } +fn write_fake_openclaw(path: &Path, output: &str) -> Result<()> { + let mut file = fs::File::create(path)?; + file.write_all(fake_openclaw_body(output).as_bytes())?; + file.sync_all()?; + drop(file); + #[cfg(unix)] + { + use std::os::unix::fs::PermissionsExt; + let mut permissions = fs::metadata(path)?.permissions(); + permissions.set_mode(0o755); + fs::set_permissions(path, permissions)?; + } + Ok(()) +} + impl SourceProvider for FakeSource { fn resolve_alias(&self, requested: &str) -> Result { Ok(self @@ -102,14 +118,7 @@ impl SourceProvider for FakeSource { let bin = staging_dir.join("node_modules").join(".bin"); fs::create_dir_all(&bin)?; let openclaw = fake_openclaw_path(bin); - fs::write(&openclaw, fake_openclaw_body(version))?; - #[cfg(unix)] - { - use std::os::unix::fs::PermissionsExt; - let mut permissions = fs::metadata(&openclaw)?.permissions(); - permissions.set_mode(0o755); - fs::set_permissions(openclaw, permissions)?; - } + write_fake_openclaw(&openclaw, version)?; Ok(()) }