From f6f33036351e79464f42b1cbc9ee3b031de8101e Mon Sep 17 00:00:00 2001 From: Kayshen-X Date: Wed, 8 Jul 2026 23:28:07 +0800 Subject: [PATCH] docs(cli): document prerelease install channel --- README.md | 20 ++++++++++++++++++++ RELEASE_NOTES/v0.8.0.md | 12 ++++++++++++ scripts/install-op.ps1 | 10 ++++++++-- scripts/install-op.sh | 12 ++++++++++-- 4 files changed, 50 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f3f872631..5efd2cc4f 100644 --- a/README.md +++ b/README.md @@ -159,12 +159,24 @@ Or use the install script (macOS / Linux): curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | bash ``` +To allow the newest pre-release: + +```bash +curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | OP_PRERELEASE=1 bash +``` + Windows PowerShell: ```powershell irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex ``` +To allow the newest pre-release: + +```powershell +$env:OP_PRERELEASE = "1"; irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex +``` + ## Cloning (with submodules) ```bash @@ -294,10 +306,18 @@ brew install zseven-w/openpencil/op curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | bash ``` +```bash +curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | OP_PRERELEASE=1 bash +``` + ```powershell irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex ``` +```powershell +$env:OP_PRERELEASE = "1"; irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex +``` + ```bash op start # Launch desktop app op design @landing.txt # Batch design from file diff --git a/RELEASE_NOTES/v0.8.0.md b/RELEASE_NOTES/v0.8.0.md index 2e7d49a32..b9f6350c0 100644 --- a/RELEASE_NOTES/v0.8.0.md +++ b/RELEASE_NOTES/v0.8.0.md @@ -28,12 +28,24 @@ macOS / Linux: curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | bash ``` +For the newest pre-release: + +```sh +curl -fsSL https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.sh | OP_PRERELEASE=1 bash +``` + Windows PowerShell: ```powershell irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex ``` +For the newest pre-release: + +```powershell +$env:OP_PRERELEASE = "1"; irm https://raw.githubusercontent.com/ZSeven-W/openpencil/main/scripts/install-op.ps1 | iex +``` + ## Docker The release workflow publishes the web image to GHCR as: diff --git a/scripts/install-op.ps1 b/scripts/install-op.ps1 index b035400d4..a6872062a 100644 --- a/scripts/install-op.ps1 +++ b/scripts/install-op.ps1 @@ -1,5 +1,6 @@ param( [string]$OpVersion = $env:OP_VERSION, + [switch]$PreRelease, [string]$InstallDir = $(if ($env:INSTALL_DIR) { $env:INSTALL_DIR } else { Join-Path $env:USERPROFILE ".openpencil\bin" }) ) @@ -19,9 +20,14 @@ function Resolve-Version { return $DefaultOpVersion.TrimStart("v") } - $Latest = Invoke-RestMethod -Uri "https://api.github.com/repos/$Owner/$Repo/releases/latest" + $AllowPreRelease = $PreRelease.IsPresent -or $env:OP_PRERELEASE -in @("1", "true", "TRUE", "yes", "YES") + if ($AllowPreRelease) { + $Latest = Invoke-RestMethod -Uri "https://api.github.com/repos/$Owner/$Repo/releases" | Select-Object -First 1 + } else { + $Latest = Invoke-RestMethod -Uri "https://api.github.com/repos/$Owner/$Repo/releases/latest" + } if (-not $Latest.tag_name) { - throw "install-op: could not resolve latest release tag; set OP_VERSION explicitly" + throw "install-op: could not resolve latest release tag; set OP_VERSION explicitly or OP_PRERELEASE=1 to allow pre-release tags" } return $Latest.tag_name.TrimStart("v") } diff --git a/scripts/install-op.sh b/scripts/install-op.sh index 672864584..db80c5c01 100755 --- a/scripts/install-op.sh +++ b/scripts/install-op.sh @@ -8,6 +8,7 @@ # Usage: # ./install-op.sh # install the latest stable release # OP_VERSION=0.8.0 ./install-op.sh # pin a specific version +# OP_PRERELEASE=1 ./install-op.sh # allow the newest pre-release # INSTALL_DIR=$HOME/.local/bin ./install-op.sh # # The release workflow stamps DEFAULT_OP_VERSION and DEFAULT_SHA_* in the copy @@ -25,6 +26,7 @@ DEFAULT_SHA_MACOS_AARCH64="" DEFAULT_SHA_MACOS_X86_64="" DEFAULT_SHA_LINUX_AARCH64="" DEFAULT_SHA_LINUX_X86_64="" +INSTALL_TMP="" detect_label() { local os arch @@ -58,11 +60,16 @@ resolve_version() { fi local api tag - api="https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" + if [ "${OP_PRERELEASE:-}" = "1" ] || [ "${OP_PRERELEASE:-}" = "true" ]; then + api="https://api.github.com/repos/${OWNER}/${REPO}/releases" + else + api="https://api.github.com/repos/${OWNER}/${REPO}/releases/latest" + fi tag="$(curl -fsSL "$api" | grep -o '"tag_name"[[:space:]]*:[[:space:]]*"[^"]*"' | head -n1 | sed 's/.*"\(v\{0,1\}[^"]*\)"$/\1/')" if [ -z "$tag" ]; then echo "error: could not resolve the latest release tag from GitHub" >&2 echo " set OP_VERSION explicitly, e.g. OP_VERSION=0.8.0 $0" >&2 + echo " or set OP_PRERELEASE=1 to allow pre-release tags" >&2 exit 1 fi printf '%s' "${tag#v}" @@ -101,7 +108,8 @@ main() { echo " from ${url}" tmp="$(mktemp -d)" - trap 'rm -rf "$tmp"' EXIT + INSTALL_TMP="$tmp" + trap 'rm -rf "$INSTALL_TMP"' EXIT curl -fsSL --retry 3 -o "$tmp/${asset}" "$url" if [ -n "$expected_sha" ]; then