-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yaml
89 lines (78 loc) · 3.39 KB
/
action.yaml
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: "PWSHUpdater"
description: "Update the runner PowerShell version to whichever version you want!"
branding:
icon: 'user-x'
color: 'purple'
inputs:
ReleaseVersion:
description: "Predefined powershell version. ('daily', 'stable', 'lts', 'preview')"
default: "stable"
FixedVersion:
description: "If a set version is wanted. ('7.1.0', 'v7.4.0-preview.4')"
runs:
using: "composite"
steps:
- shell: pwsh
id: LinuxAndOsx
if: runner.os == 'Linux' || runner.os == 'macOS'
run: |
try {
. "$env:GITHUB_ACTION_PATH/UpgradePwsh.ps1"
if (-not ( [string]::IsNullOrEmpty("${{ inputs.FixedVersion }}") ) ) {
Write-Host "::notice::Trying to install fixed PowerShell version ${{ inputs.FixedVersion }}"
if ($IsLinux) {
$OS = 'linux'
$unameOutput = uname -m
switch -Wildcard ($unameOutput) {
'x86_64' { $architecture = 'x64' }
'aarch64*' { $architecture = 'arm64' }
'armv8*' { $architecture = 'arm64' }
}
}
elseif ($IsMacOS) {
$OS = 'osx'
$unameOutput = uname -m
switch ($unameOutput) {
'x86_64' { $architecture = 'x64' }
'arm64' { $architecture = 'arm64' }
}
}
$DownloadedPwsh = Invoke-PowerShellVersionDownload -Version ${{ inputs.FixedVersion }} -OperatingSystem $OS -Architecture $architecture -Verbose
}
else {
Write-Host "::notice::Installing PowerShell version ${{ inputs.ReleaseVersion }}"
$DownloadedPwsh = Invoke-PowerShellVersionDownload -ReleaseVersion ${{ inputs.ReleaseVersion }} -Verbose
}
Install-PowerShellVersion -ArchiveFile $DownloadedPwsh -Verbose
}
catch {
Write-Error "::Error::Failed to upgrade PWSH version. This _may_ mean your runner now doesn't work. Error: $($_.Exception.message)"
exit 1
}
- shell: PowerShell
id: Windows
if: runner.os == 'Windows'
run: |
try {
. "$env:GITHUB_ACTION_PATH/UpgradePwsh.ps1"
if (-not ( [string]::IsNullOrEmpty("${{ inputs.FixedVersion }}") ) ) {
Write-Host "::notice::Trying to install fixed PowerShell version ${{ inputs.FixedVersion }}"
$OS = 'win'
switch ($env:PROCESSOR_ARCHITECTURE) {
'AMD64' { $architecture = 'x64' }
'x86' { $architecture = 'x86' }
'ARM64' { $architecture = 'arm64' }
default { throw "PowerShell package for OS architecture '$_' is not supported." }
}
$DownloadedPwsh = Invoke-PowerShellVersionDownload -Version ${{ inputs.FixedVersion }} -OperatingSystem $OS -Architecture $architecture -Verbose
}
else {
Write-Host "::notice::Installing PowerShell version ${{ inputs.ReleaseVersion }}"
$DownloadedPwsh = Invoke-PowerShellVersionDownload -ReleaseVersion ${{ inputs.ReleaseVersion }} -Verbose
}
Install-PowerShellVersion -ArchiveFile $DownloadedPwsh -Verbose
}
catch {
Write-Error "::Error::Failed to upgrade PWSH version. This _may_ mean your runner now doesn't work. Error: $($_.Exception.message)"
exit 1
}