From 863228809752c58fb5e9fd3db42cd7584e496d0f Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Tue, 19 May 2020 13:26:04 +0500 Subject: [PATCH] Install GitHub CLI on Windows images (#853) * Install GitHub CLI on Windows images * Resolve comments Co-authored-by: Sergey Dolin --- images/win/Windows2016-Azure.json | 12 +++++++++ images/win/Windows2019-Azure.json | 12 +++++++++ .../scripts/Installers/Install-GitHub-CLI.ps1 | 10 +++++++ .../Installers/Validate-GitHub-CLI.ps1 | 27 +++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 images/win/scripts/Installers/Install-GitHub-CLI.ps1 create mode 100644 images/win/scripts/Installers/Validate-GitHub-CLI.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index 8c29d155..945e7974 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -370,6 +370,12 @@ "{{ template_dir }}/scripts/Installers/Install-Git.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-GitHub-CLI.ps1" + ] + }, { "type": "powershell", "environment_vars": [ @@ -719,6 +725,12 @@ "{{ template_dir }}/scripts/Installers/Validate-Git.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-GitHub-CLI.ps1" + ] + }, { "type": "powershell", "environment_vars": [ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index deecbe6f..aa008e02 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -343,6 +343,12 @@ "{{ template_dir }}/scripts/Installers/Install-Git.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Install-GitHub-CLI.ps1" + ] + }, { "type": "powershell", "environment_vars": [ @@ -716,6 +722,12 @@ "{{ template_dir }}/scripts/Installers/Validate-Git.ps1" ] }, + { + "type": "powershell", + "scripts":[ + "{{ template_dir }}/scripts/Installers/Validate-GitHub-CLI.ps1" + ] + }, { "type": "powershell", "environment_vars": [ diff --git a/images/win/scripts/Installers/Install-GitHub-CLI.ps1 b/images/win/scripts/Installers/Install-GitHub-CLI.ps1 new file mode 100644 index 00000000..5fb49887 --- /dev/null +++ b/images/win/scripts/Installers/Install-GitHub-CLI.ps1 @@ -0,0 +1,10 @@ +################################################################################ +## File: Install-GitHub-CLI.ps1 +## Desc: Install GitHub CLI +################################################################################ + +Import-Module -Name ImageHelpers -Force + +Choco-Install -PackageName gh + +Add-MachinePathItem "C:\Program Files (x86)\GitHub CLI" \ No newline at end of file diff --git a/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 b/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 new file mode 100644 index 00000000..fa9f2bf1 --- /dev/null +++ b/images/win/scripts/Installers/Validate-GitHub-CLI.ps1 @@ -0,0 +1,27 @@ +################################################################################ +## File: Validate-GitHub-CLI.ps1 +## Desc: Validate GitHub CLI +################################################################################ + +$command = Get-Command -Name 'gh' + +if ($command) +{ + Write-Host "gh on path" +} +else +{ + Write-Host 'gh is not on path' + exit 1 +} + +# Adding description of the software to Markdown +$SoftwareName = "GitHub CLI" + +$version = (gh --version).Split()[2] + +$Description = @" +_Version:_ $version
+"@ + +Add-SoftwareDetailsToMarkdown -SoftwareName $SoftwareName -DescriptionMarkdown $Description \ No newline at end of file