Skip to content

Commit 6ec9fa1

Browse files
Sniderclaude
andcommitted
fix(install): use latest release instead of hardcoded version
- install-core.sh: Auto-detect latest release via gh/curl (was hardcoded v0.1.0) - install-core.ps1: Add Get-LatestVersion for build-from-source path - install-deps.sh: Fix bash 3 compatibility (${var,,} → tr) - README.md: Fix command (core health → core dev health) - Fix CRLF line endings in shell scripts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent ec2e1c9 commit 6ec9fa1

4 files changed

Lines changed: 52 additions & 6 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ You're now ready to develop. The workspace starts with `core-php` as the active
3232
core doctor
3333

3434
# See workspace status
35-
core health
35+
core dev health
3636

3737
# Run tests in the active package (core-php)
3838
core php test

scripts/install-core.ps1

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ if ($PSVersionTable.PSVersion.Major -lt 4) {
2929
$Repo = "host-uk/core"
3030
$MinDiskSpaceMB = 100 # Minimum required disk space in MB
3131

32+
# Resolve latest release version from GitHub API
33+
function Get-LatestVersion {
34+
try {
35+
if (Test-Command gh) {
36+
$version = gh release view --repo $Repo --json tagName -q '.tagName' 2>$null
37+
if ($version) { return $version }
38+
}
39+
40+
# Fallback to GitHub API
41+
$response = Invoke-RestMethod -Uri "https://api.github.com/repos/$Repo/releases/latest" -UseBasicParsing
42+
if ($response.tag_name) { return $response.tag_name }
43+
} catch {
44+
Write-Warn "Could not determine latest version, using default branch"
45+
}
46+
return $null
47+
}
48+
3249
function Write-Info { Write-Host "[INFO] $args" -ForegroundColor Green }
3350
function Write-Warn { Write-Host "[WARN] $args" -ForegroundColor Yellow }
3451
function Write-Err { Write-Host "[ERROR] $args" -ForegroundColor Red; exit 1 }
@@ -339,11 +356,23 @@ function Build-FromSource {
339356
$null = Set-SecureDirectoryAcl -Path $tmpdir -Required
340357

341358
try {
359+
# Resolve latest version for reproducible builds
360+
$version = Get-LatestVersion
361+
if ($version) {
362+
Write-Info "Resolved latest version: $version"
363+
} else {
364+
Write-Warn "Building from default branch (version unknown)"
365+
}
366+
342367
Write-Info "Cloning $Repo..."
343368
$cloneDir = Join-Path $tmpdir "Core"
344369

345-
# Clone default branch
346-
git clone --depth 1 "https://github.com/$Repo.git" $cloneDir
370+
# Clone specific version if available, otherwise default branch
371+
if ($version) {
372+
git clone --depth 1 --branch $version "https://github.com/$Repo.git" $cloneDir
373+
} else {
374+
git clone --depth 1 "https://github.com/$Repo.git" $cloneDir
375+
}
347376
if ($LASTEXITCODE -ne 0) {
348377
Write-Err "Failed to clone repository"
349378
}

scripts/install-core.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,24 @@ set -e
2121
# - No TLS certificate pinning (relies on system CA store)
2222

2323
REPO="host-uk/core"
24-
VERSION="v0.1.0" # Pinned version - update when releasing new versions
24+
VERSION="${CORE_VERSION:-latest}" # Use latest release, or set CORE_VERSION=dev for dev builds
2525
INSTALL_DIR="${INSTALL_DIR:-$HOME/.local/bin}"
2626
BUILD_FROM_SOURCE="${BUILD_FROM_SOURCE:-auto}"
2727

28+
# Resolve "latest" to actual release tag
29+
resolve_version() {
30+
if [[ "$VERSION" == "latest" ]]; then
31+
if has gh; then
32+
VERSION=$(gh release view --repo "$REPO" --json tagName -q '.tagName' 2>/dev/null) || VERSION="dev"
33+
elif has curl; then
34+
VERSION=$(curl -fsSL "https://api.github.com/repos/$REPO/releases/latest" 2>/dev/null | grep '"tag_name"' | head -1 | cut -d'"' -f4) || VERSION="dev"
35+
else
36+
VERSION="dev"
37+
fi
38+
info "Resolved latest version: $VERSION"
39+
fi
40+
}
41+
2842
RED='\033[0;31m'
2943
GREEN='\033[0;32m'
3044
YELLOW='\033[1;33m'
@@ -75,7 +89,8 @@ verify_hash() {
7589

7690
actual_hash=$(compute_sha256 "$file")
7791

78-
if [[ "${actual_hash,,}" != "${expected_hash,,}" ]]; then
92+
# Case-insensitive compare (bash 3 compatible)
93+
if [[ "$(echo "$actual_hash" | tr '[:upper:]' '[:lower:]')" != "$(echo "$expected_hash" | tr '[:upper:]' '[:lower:]')" ]]; then
7994
rm -f "$file"
8095
error "Hash verification failed! Expected: $expected_hash, Got: $actual_hash. The downloaded file may be corrupted or tampered with."
8196
fi
@@ -282,6 +297,7 @@ verify() {
282297
}
283298

284299
main() {
300+
resolve_version
285301
info "Installing Core CLI (version $VERSION)..."
286302

287303
# Verify install directory is safe before starting

scripts/install-deps.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ verify_hash() {
4444

4545
actual_hash=$(compute_sha256 "$file")
4646

47-
if [[ "${actual_hash,,}" != "${expected_hash,,}" ]]; then
47+
# Case-insensitive compare (bash 3 compatible)
48+
if [[ "$(echo "$actual_hash" | tr '[:upper:]' '[:lower:]')" != "$(echo "$expected_hash" | tr '[:upper:]' '[:lower:]')" ]]; then
4849
rm -f "$file"
4950
error "Hash verification failed! Expected: $expected_hash, Got: $actual_hash"
5051
fi

0 commit comments

Comments
 (0)