|
1 | | -name: {{ NAME }} |
2 | | -description: {{ DESCRIPTION }} |
| 1 | +name: Install-PowerShell |
| 2 | +description: Install PowerShell |
3 | 3 | author: PSModule |
4 | 4 | branding: |
5 | 5 | icon: upload-cloud |
6 | 6 | color: white |
7 | 7 |
|
8 | 8 | inputs: |
9 | | - subject: |
10 | | - description: The subject to greet |
11 | | - required: false |
12 | | - default: World |
13 | | - Debug: |
14 | | - description: Enable debug output. |
15 | | - required: false |
16 | | - default: 'false' |
17 | | - Verbose: |
18 | | - description: Enable verbose output. |
19 | | - required: false |
20 | | - default: 'false' |
21 | 9 | Version: |
22 | | - description: Specifies the version of the GitHub module to be installed. The value must be an exact version. |
23 | | - required: false |
24 | | - Prerelease: |
25 | | - description: Allow prerelease versions if available. |
| 10 | + description: The version of PowerShell to install, i.e. 7.4.0 or 7.5.0. If not provided it, latest version is installed. |
26 | 11 | required: false |
27 | | - default: 'false' |
28 | | - WorkingDirectory: |
29 | | - description: The working directory where the script will run from. |
30 | | - required: false |
31 | | - default: ${{ github.workspace }} |
| 12 | + default: '' |
32 | 13 |
|
33 | 14 | runs: |
34 | 15 | using: composite |
35 | 16 | steps: |
36 | | - - name: {{ NAME }} |
37 | | - uses: PSModule/GitHub-Script@v1 |
38 | | - env: |
39 | | - {{ ORG }}_{{ NAME }}_INPUT_subject: ${{ inputs.subject }} |
40 | | - with: |
41 | | - Debug: ${{ inputs.Debug }} |
42 | | - Prerelease: ${{ inputs.Prerelease }} |
43 | | - Verbose: ${{ inputs.Verbose }} |
44 | | - Version: ${{ inputs.Version }} |
45 | | - WorkingDirectory: ${{ inputs.WorkingDirectory }} |
46 | | - Script: | |
47 | | - # {{ NAME }} |
48 | | - ${{ github.action_path }}/scripts/main.ps1 |
| 17 | + - name: Install PowerShell on Windows |
| 18 | + if: runner.os == 'Windows' |
| 19 | + shell: powershell |
| 20 | + run: | |
| 21 | + $version = '${{ inputs.version }}' |
| 22 | + winget uninstall --id Microsoft.PowerShell --accept-source-agreements --accept-package-agreements |
| 23 | + if ([string]::IsNullOrWhiteSpace($version)) { |
| 24 | + winget install --id Microsoft.PowerShell --source winget --accept-package-agreements --accept-source-agreements |
| 25 | + } |
| 26 | + else { |
| 27 | + winget install --id Microsoft.PowerShell --version $version --source winget --accept-package-agreements --accept-source-agreements |
| 28 | + } |
| 29 | +
|
| 30 | + - name: Install PowerShell on Ubuntu |
| 31 | + if: runner.os == 'Linux' |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + sudo apt-get remove powershell -y |
| 35 | + version='${{ inputs.version }}' |
| 36 | + if [ -z "$version" ]; then |
| 37 | + version=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep 'tag_name' | cut -d '"' -f 4) |
| 38 | + else |
| 39 | + version="v$version" |
| 40 | + fi |
| 41 | + wget https://github.com/PowerShell/PowerShell/releases/download/$version/powershell_${version#v}-1.deb_amd64.deb |
| 42 | + sudo dpkg -i powershell_${version#v}-1.deb_amd64.deb |
| 43 | + sudo apt-get install -f |
| 44 | +
|
| 45 | + - name: Install PowerShell on macOS |
| 46 | + if: runner.os == 'macOS' |
| 47 | + shell: bash |
| 48 | + run: | |
| 49 | + sudo rm -rf /usr/local/microsoft/powershell |
| 50 | + version='${{ inputs.version }}' |
| 51 | + if [ -z "$version" ]; then |
| 52 | + version=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | grep 'tag_name' | cut -d '"' -f 4) |
| 53 | + else |
| 54 | + version="v$version" |
| 55 | + fi |
| 56 | + pkg="powershell-${version#v}-osx.pkg" |
| 57 | + url="https://github.com/PowerShell/PowerShell/releases/download/$version/$pkg" |
| 58 | + curl -LO $url |
| 59 | + sudo installer -pkg $pkg -target / |
0 commit comments