@@ -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+
3249function Write-Info { Write-Host " [INFO] $args " - ForegroundColor Green }
3350function Write-Warn { Write-Host " [WARN] $args " - ForegroundColor Yellow }
3451function 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 }
0 commit comments