Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions .github/actions/setup-powershell/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,38 +8,42 @@ inputs:
runs:
using: composite
steps:
# Set global environment variable for all subsequent steps
- run: echo "POWERSHELL_VERSION=${{ inputs.version }}" >> $GITHUB_ENV
shell: bash

# Download the powershell '.tar.gz' archive
- run: curl -L -o /tmp/powershell.tar.gz https://github.com/PowerShell/PowerShell/releases/download/v${{ inputs.version }}/powershell-${{ inputs.version }}-linux-x64.tar.gz
- run: curl -L -o /tmp/powershell.tar.gz "https://github.com/PowerShell/PowerShell/releases/download/v$POWERSHELL_VERSION/powershell-$POWERSHELL_VERSION-linux-x64.tar.gz"
shell: bash

# Create the target folder where powershell will be placed
- run: sudo mkdir -p /opt/microsoft/powershell/${{ inputs.version }}
- run: sudo mkdir -p "/opt/microsoft/powershell/$POWERSHELL_VERSION"
shell: bash

# Expand powershell to the target folder
- run: sudo tar zxf /tmp/powershell.tar.gz -C /opt/microsoft/powershell/${{ inputs.version }}
- run: sudo tar zxf /tmp/powershell.tar.gz -C "/opt/microsoft/powershell/$POWERSHELL_VERSION"
shell: bash

# Set execute permissions
- run: sudo chmod +x /opt/microsoft/powershell/${{ inputs.version }}/pwsh
- run: sudo chmod +x "/opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh"
shell: bash

# Unlink the original pwsh binary already present in the system
- run: sudo unlink /usr/bin/pwsh
shell: bash

# Create the symbolic link that points to pwsh
- run: sudo ln -s /opt/microsoft/powershell/${{ inputs.version }}/pwsh /usr/bin/pwsh
- run: sudo ln -s "/opt/microsoft/powershell/$POWERSHELL_VERSION/pwsh" /usr/bin/pwsh
shell: bash

# Verify the installation by checking the `pwsh` command version.
- run: |
pwsh --version
[[ "$(pwsh --version)" == "PowerShell ${{ inputs.version }}" ]]
[[ "$(pwsh --version)" == "PowerShell $POWERSHELL_VERSION" ]]
shell: bash

# Verify the installation by using the `pwsh` shell.
- run: |
$PSVersionTable
if ( $PSVersionTable.PSVersion.ToString() -ne "${{ inputs.version }}" ) { exit 1 }
if ( $PSVersionTable.PSVersion.ToString() -ne "$env:POWERSHELL_VERSION" ) { exit 1 }
shell: pwsh
Loading