-
Notifications
You must be signed in to change notification settings - Fork 0
Add nfpms, Scoop, and install scripts #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| # Install the Emailable CLI on Windows. | ||
| # | ||
| # Usage (PowerShell): | ||
| # irm https://emailable.com/install-cli.ps1 | iex | ||
| # | ||
| # Environment overrides: | ||
| # $env:EMAILABLE_VERSION Specific version to install (e.g. v0.2.0). | ||
| # Defaults to the latest GitHub release. | ||
| # $env:EMAILABLE_PREFIX Install prefix. Defaults to | ||
| # "$env:LOCALAPPDATA\Programs\emailable". The | ||
| # binary lands directly under this directory. | ||
|
|
||
| $ErrorActionPreference = 'Stop' | ||
|
|
||
| $Repo = 'emailable/emailable-cli' | ||
| $Binary = 'emailable' | ||
|
|
||
| function Abort([string]$msg) { | ||
| Write-Host "Error: $msg" -ForegroundColor Red | ||
| exit 1 | ||
| } | ||
|
|
||
| # --- detect architecture -------------------------------------------------- | ||
|
|
||
| # A 32-bit PowerShell on 64-bit Windows reports x86 in PROCESSOR_ARCHITECTURE; | ||
| # PROCESSOR_ARCHITEW6432 holds the true machine arch in that case. | ||
| $procArch = $env:PROCESSOR_ARCHITEW6432 | ||
| if (-not $procArch) { $procArch = $env:PROCESSOR_ARCHITECTURE } | ||
|
|
||
| $arch = switch ($procArch) { | ||
| 'AMD64' { 'amd64' } | ||
| 'ARM64' { 'arm64' } | ||
| default { Abort "unsupported architecture: $procArch" } | ||
| } | ||
|
|
||
| # --- resolve version ------------------------------------------------------ | ||
|
|
||
| $version = $env:EMAILABLE_VERSION | ||
| if (-not $version) { | ||
| try { | ||
| $resp = Invoke-WebRequest -UseBasicParsing -MaximumRedirection 0 ` | ||
| -Uri "https://github.com/$Repo/releases/latest" -ErrorAction SilentlyContinue | ||
| } catch { | ||
| $resp = $_.Exception.Response | ||
| } | ||
| $location = $null | ||
| if ($resp -and $resp.Headers) { $location = $resp.Headers['Location'] } | ||
| if (-not $location) { Abort "could not determine latest version" } | ||
| $version = ($location -split '/tag/')[-1] | ||
| } | ||
| $version = $version.TrimStart('v') | ||
| $tag = "v$version" | ||
|
|
||
| # --- pick prefix ---------------------------------------------------------- | ||
|
|
||
| $prefix = $env:EMAILABLE_PREFIX | ||
| if (-not $prefix) { | ||
| $prefix = Join-Path $env:LOCALAPPDATA 'Programs\emailable' | ||
| } | ||
| New-Item -ItemType Directory -Force -Path $prefix | Out-Null | ||
|
|
||
| # --- download & verify ---------------------------------------------------- | ||
|
|
||
| $archive = "${Binary}_${version}_windows_${arch}.zip" | ||
| $baseUrl = "https://github.com/$Repo/releases/download/$tag" | ||
|
|
||
| $tmp = Join-Path ([IO.Path]::GetTempPath()) ([Guid]::NewGuid().ToString()) | ||
| New-Item -ItemType Directory -Force -Path $tmp | Out-Null | ||
| try { | ||
| Write-Host "Downloading $archive from $tag..." | ||
| Invoke-WebRequest -UseBasicParsing -Uri "$baseUrl/$archive" -OutFile (Join-Path $tmp $archive) | ||
| Invoke-WebRequest -UseBasicParsing -Uri "$baseUrl/checksums.txt" -OutFile (Join-Path $tmp 'checksums.txt') | ||
|
|
||
| Write-Host "Verifying checksum..." | ||
| $expected = (Get-Content (Join-Path $tmp 'checksums.txt') ` | ||
| | Where-Object { $_ -match " $([regex]::Escape($archive))$" } ` | ||
| | ForEach-Object { ($_ -split '\s+')[0] } ` | ||
| | Select-Object -First 1) | ||
| if (-not $expected) { Abort "no checksum entry for $archive" } | ||
|
|
||
| $actual = (Get-FileHash -Algorithm SHA256 (Join-Path $tmp $archive)).Hash.ToLower() | ||
| if ($expected.ToLower() -ne $actual) { | ||
| Abort "checksum mismatch (expected $expected, got $actual)" | ||
| } | ||
|
|
||
| Write-Host "Installing to $prefix\$Binary.exe..." | ||
| Expand-Archive -Force -LiteralPath (Join-Path $tmp $archive) -DestinationPath $tmp | ||
| Copy-Item -Force -Path (Join-Path $tmp "$Binary.exe") -Destination (Join-Path $prefix "$Binary.exe") | ||
| } finally { | ||
| Remove-Item -Recurse -Force -Path $tmp -ErrorAction SilentlyContinue | ||
| } | ||
|
|
||
| # --- ensure prefix is on the user PATH ------------------------------------ | ||
|
|
||
| $userPath = [Environment]::GetEnvironmentVariable('Path', 'User') | ||
| if (-not $userPath) { $userPath = '' } | ||
| $pathParts = $userPath -split ';' | Where-Object { $_ -ne '' } | ||
| if (-not ($pathParts -contains $prefix)) { | ||
| $newPath = if ($userPath) { "$userPath;$prefix" } else { $prefix } | ||
| [Environment]::SetEnvironmentVariable('Path', $newPath, 'User') | ||
| Write-Host "Added $prefix to your user PATH. Open a new terminal to pick up the change." -ForegroundColor Yellow | ||
| } | ||
|
|
||
| Write-Host "Installed $Binary $version to $prefix\$Binary.exe" -ForegroundColor Green |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.