forked from fleschutz/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-github-cli.ps1
executable file
·34 lines (32 loc) · 979 Bytes
/
install-github-cli.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
Installs GitHub CLI
.DESCRIPTION
This PowerShell script installs the GitHub command-line interface (CLI).
.EXAMPLE
PS> ./install-github-cli.ps1
⏳ Installing GitHub CLI...
✔ GitHub CLI installed successfully in 17s - to authenticate execute: 'gh auth login'.
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
"⏳ Installing GitHub CLI..."
$stopWatch = [system.diagnostics.stopwatch]::startNew()
if ($IsMacOS) {
& brew install gh
} elseif ($IsLinux) {
& sudo apt install gh
} else {
& winget install --id GitHub.cli
if ($lastExitCode -ne "0") { throw "Installation of GitHub CLI failed, maybe it's already installed." }
}
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
"✅ GitHub CLI installed successfully in $($elapsed)s - to authenticate execute: 'gh auth login'"
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}