Skip to content

Commit 8610845

Browse files
Enhance GitHub Action to support multiple OS and PowerShell versions; remove unused scripts and test placeholders.
1 parent e8f11bb commit 8610845

File tree

4 files changed

+53
-66
lines changed

4 files changed

+53
-66
lines changed

.github/workflows/Action-Test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ permissions:
1818

1919
jobs:
2020
ActionTestBasic:
21+
strategy:
22+
matrix:
23+
os: [ubuntu-latest, windows-latest, macOS-latest]
24+
version: ['7.4.0', '7.5.0'] # Specify the versions to test
2125
name: Action-Test - [Basic]
22-
runs-on: ubuntu-latest
26+
runs-on: ${{ matrix.os }}
2327
steps:
2428
# Need to check out as part of the test, as its a local action
2529
- name: Checkout repo
@@ -28,5 +32,4 @@ jobs:
2832
- name: Action-Test
2933
uses: ./
3034
with:
31-
working-directory: ./tests
32-
subject: PSModule
35+
Version: ${{ matrix.version }}

action.yml

Lines changed: 47 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,59 @@
1-
name: {{ NAME }}
2-
description: {{ DESCRIPTION }}
1+
name: Install-PowerShell
2+
description: Install PowerShell
33
author: PSModule
44
branding:
55
icon: upload-cloud
66
color: white
77

88
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'
219
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.
2611
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: ''
3213

3314
runs:
3415
using: composite
3516
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 /

scripts/main.ps1

Lines changed: 0 additions & 24 deletions
This file was deleted.

tests/README.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)