44#
55# Set the package name and version to install
66#
7+ param (
8+ [Parameter ()]
9+ [String ]$$ VERSION = " $version $"
10+ )
11+ [String ]$$ PKG_VERSION = [Environment ]::GetEnvironmentVariable(" PKG_VERSION" )
12+ if ($$ PKG_VERSION) {
13+ $$ VERSION = " $$ {PKG_VERSION}"
14+ Write-Output " Using '$$ {PKG_VERSION}' for version value '$$ {VERSION}'"
15+ }
16+
717$$ PACKAGE = " $name $"
8- $$ VERSION = " $version $"
918$$ GIT_GROUP = " $git_org_or_person $"
1019$$ RELEASE = " https://github.com/$$ {GIT_GROUP}/$$ {PACKAGE}/releases/tag/v$$ {VERSION}"
1120$$ SYSTEM_TYPE = Get-ComputerInfo - Property CsSystemType
@@ -15,34 +24,39 @@ if ($$SYSTEM_TYPE.CsSystemType.Contains("ARM64")) {
1524 $$ MACHINE = " x86_64"
1625}
1726
27+
1828# FIGURE OUT Install directory
1929$$ BIN_DIR = " $$ {Home}\bin"
20- Write-Output " $$ {PACKAGE} will be installed in $$ {BIN_DIR}"
30+ Write-Output " $$ {PACKAGE} v $$ {VERSION} will be installed in $$ {BIN_DIR}"
2131
2232#
2333# Figure out what the zip file is named
2434#
2535$$ ZIPFILE = " $$ {PACKAGE}-v$$ {VERSION}-Windows-$$ {MACHINE}.zip"
36+ Write-Output " Fetching Zipfile $$ {ZIPFILE}"
2637
2738#
2839# Check to see if this zip file has been downloaded.
2940#
3041$$ DOWNLOAD_URL = " https://github.com/$$ {GIT_GROUP}/$$ {PACKAGE}/releases/download/v$$ {VERSION}/$$ {ZIPFILE}"
42+ Write-Output " Download URL $$ {DOWNLOAD_URL}"
3143
3244if (! (Test-Path $$ BIN_DIR)) {
3345 New-Item $$ BIN_DIR - ItemType Directory | Out-Null
3446}
3547curl.exe - Lo " $$ {ZIPFILE}" " $$ {DOWNLOAD_URL}"
36-
37- tar.exe xf " $$ {ZIPFILE}" - C " $$ {Home}"
38-
39- Remove-Item $$ ZIPFILE
40-
41- $$ User = [System.EnvironmentVariableTarget ]::User
42- $$ Path = [System.Environment ]::GetEnvironmentVariable(' Path' , $$ User)
43- if (! (" ;$$ {Path};" .ToLower() -like " *;$$ {BIN_DIR};*" .ToLower())) {
44- [System.Environment ]::SetEnvironmentVariable(' Path' , " $$ {Path};$$ {BIN_DIR}" , $$ User)
45- $$ Env:Path += " ;$$ {BIN_DIR}"
48+ # if ([System.IO.File]::Exists($$ZIPFILE)) {
49+ if (! (Test-Path $$ ZIPFILE)) {
50+ Write-Output " Failed to download $$ {ZIPFILE} from $$ {DOWNLOAD_URL}"
51+ } else {
52+ tar.exe xf " $$ {ZIPFILE}" - C " $$ {Home}"
53+ # Remove-Item $$ZIPFILE
54+
55+ $$ User = [System.EnvironmentVariableTarget ]::User
56+ $$ Path = [System.Environment ]::GetEnvironmentVariable(' Path' , $$ User)
57+ if (! (" ;$$ {Path};" .ToLower() -like " *;$$ {BIN_DIR};*" .ToLower())) {
58+ [System.Environment ]::SetEnvironmentVariable(' Path' , " $$ {Path};$$ {BIN_DIR}" , $$ User)
59+ $$ Env:Path += " ;$$ {BIN_DIR}"
60+ }
61+ Write-Output " $$ {PACKAGE} was installed successfully to $$ {BIN_DIR}"
4662}
47-
48- Write-Output " $$ {PACKAGE} was installed successfully to $$ {BIN_DIR}"
0 commit comments