1
+ # install_yek.ps1
2
+ # Install Yek on Windows via PowerShell
3
+ param (
4
+ [string ]$InstallDir = " $HOME \.local\bin"
5
+ )
6
+
7
+ # Exit on error
8
+ $ErrorActionPreference = " Stop"
9
+
10
+ Write-Host " Yek Windows Installer"
11
+
12
+ if (! (Test-Path - Path $InstallDir )) {
13
+ New-Item - ItemType Directory - Force - Path $InstallDir | Out-Null
14
+ }
15
+
16
+ Write-Host " Selected install directory: $InstallDir "
17
+
18
+ # Detect architecture
19
+ $arch = $ENV: PROCESSOR_ARCHITECTURE
20
+ switch ($arch ) {
21
+ " AMD64" { $target = " x86_64-pc-windows-msvc" }
22
+ " ARM64" { $target = " aarch64-pc-windows-msvc" }
23
+ default {
24
+ Write-Host " Unsupported or unknown architecture: $arch "
25
+ Write-Host " Please build from source or check for a compatible artifact."
26
+ exit 1
27
+ }
28
+ }
29
+
30
+ $repoOwner = " bodo-run"
31
+ $repoName = " yek"
32
+ $assetName = " yek-$target .zip"
33
+
34
+ Write-Host " OS/ARCH => Windows / $arch "
35
+ Write-Host " Asset name => $assetName "
36
+
37
+ Write-Host " Fetching latest release info from GitHub..."
38
+ $releasesUrl = " https://api.github.com/repos/$repoOwner /$repoName /releases/latest"
39
+ try {
40
+ $releaseData = Invoke-RestMethod - Uri $releasesUrl
41
+ } catch {
42
+ Write-Host " Failed to fetch release info from GitHub."
43
+ Write-Host " Please build from source or check back later."
44
+ exit 0
45
+ }
46
+
47
+ # Find the asset download URL
48
+ $asset = $releaseData.assets | Where-Object { $_.name -eq $assetName }
49
+ if (! $asset ) {
50
+ Write-Host " Failed to find an asset named $assetName in the latest release."
51
+ Write-Host " Check that your OS/ARCH is built or consider building from source."
52
+ exit 0
53
+ }
54
+
55
+ $downloadUrl = $asset.browser_download_url
56
+ Write-Host " Downloading from: $downloadUrl "
57
+
58
+ $zipPath = Join-Path $env: TEMP $assetName
59
+ Invoke-WebRequest - Uri $downloadUrl - OutFile $zipPath - UseBasicParsing
60
+
61
+ Write-Host " Extracting archive..."
62
+ $extractDir = Join-Path $env: TEMP " yek-$ ( $arch ) "
63
+ if (Test-Path $extractDir ) {
64
+ Remove-Item - Recurse - Force $extractDir
65
+ }
66
+ Expand-Archive - Path $zipPath - DestinationPath $extractDir
67
+
68
+ Write-Host " Moving binary to $InstallDir ..."
69
+ $binaryPath = Join-Path $extractDir " yek-$target " " yek.exe"
70
+ if (! (Test-Path $binaryPath )) {
71
+ Write-Host " yek.exe not found in the extracted folder."
72
+ exit 1
73
+ }
74
+ Move-Item - Force $binaryPath $InstallDir
75
+
76
+ Write-Host " Cleanup temporary files..."
77
+ Remove-Item - Force $zipPath
78
+ Remove-Item - Recurse - Force $extractDir
79
+
80
+ Write-Host " Installation complete!"
81
+
82
+ # Check if $InstallDir is in PATH
83
+ $pathDirs = $ENV: PATH -split " ;"
84
+ if ($pathDirs -notcontains (Resolve-Path $InstallDir )) {
85
+ Write-Host " NOTE: $InstallDir is not in your PATH. Add it by running something like:"
86
+ Write-Host " `$ env:Path += `" ;$ ( Resolve-Path $InstallDir ) `" "
87
+ Write-Host " Or update your system's environment variables to persist this."
88
+ }
89
+
90
+ Write-Host " Now you can run: yek --help"
0 commit comments