|
1 | | -name: "Install PowerShell" |
2 | | -description: "Install a specific version of PowerShell Core on any GitHub runner (Linux, macOS, Windows). Handles install, downgrade, or forced reinstall with uniform logging." |
3 | | -author: "Your Org" |
| 1 | +name: Install PowerShell |
| 2 | +description: Install a specific version of PowerShell Core on any GitHub runner (Linux, macOS, Windows). Handles install, downgrade, or forced reinstall with uniform logging. |
| 3 | +author: PSModule |
4 | 4 | branding: |
5 | | - icon: "terminal" |
6 | | - color: "purple" |
| 5 | + icon: terminal |
| 6 | + color: purple |
7 | 7 |
|
8 | 8 | inputs: |
9 | | - version: |
10 | | - description: "Exact PowerShell version to install (e.g. 7.4.1)" |
| 9 | + Version: |
| 10 | + description: Exact PowerShell version to install (e.g. 7.4.1) |
11 | 11 | required: true |
12 | | - reinstall: |
13 | | - description: "Set to 'true' to uninstall & reinstall even when the exact version is already present." |
14 | | - default: "false" |
15 | | - package-source: |
16 | | - description: "Package source: 'microsoft' (default), 'github', or custom direct URL to the archive/MSI." |
17 | | - default: "microsoft" |
| 12 | + Reinstall: |
| 13 | + description: Set to 'true' to uninstall & reinstall even when the exact version is already present. |
| 14 | + default: 'false' |
18 | 15 |
|
19 | 16 | runs: |
20 | | - using: "composite" |
| 17 | + using: composite |
21 | 18 | steps: |
22 | | - # --------------------------------------------------------------------- |
23 | | - # Common environment |
24 | | - # --------------------------------------------------------------------- |
25 | 19 | - name: Set shared env |
26 | 20 | shell: bash |
27 | 21 | run: | |
28 | | - echo "REQUESTED_VERSION=${{ inputs.version }}" >> $GITHUB_ENV |
29 | | - echo "REINSTALL=${{ inputs.reinstall }}" >> $GITHUB_ENV |
30 | | - echo "PACKAGE_SOURCE=${{ inputs['package-source'] }}" >> $GITHUB_ENV |
| 22 | + echo "REQUESTED_VERSION=${{ inputs.Version }}" >> $GITHUB_ENV |
| 23 | + echo "REINSTALL=${{ inputs.Reinstall }}" >> $GITHUB_ENV |
31 | 24 |
|
32 | | - # --------------------------------------------------------------------- |
33 | | - # Linux installer ------------------------------------------------------ |
34 | | - # --------------------------------------------------------------------- |
35 | 25 | - name: Install PowerShell (Linux) |
36 | 26 | if: runner.os == 'Linux' |
37 | 27 | id: linux |
|
71 | 61 | echo "pwsh-path=$PWSH_PATH" >> $GITHUB_OUTPUT |
72 | 62 | echo "pwsh-version=$REQUESTED_VERSION" >> $GITHUB_OUTPUT |
73 | 63 |
|
74 | | - # --------------------------------------------------------------------- |
75 | | - # macOS installer ------------------------------------------------------ |
76 | | - # --------------------------------------------------------------------- |
77 | 64 | - name: Install PowerShell (macOS) |
78 | 65 | if: runner.os == 'macOS' |
79 | 66 | id: macos |
@@ -113,9 +100,6 @@ runs: |
113 | 100 | echo "pwsh-path=$PWSH_PATH" >> $GITHUB_OUTPUT |
114 | 101 | echo "pwsh-version=$REQUESTED_VERSION" >> $GITHUB_OUTPUT |
115 | 102 |
|
116 | | - # --------------------------------------------------------------------- |
117 | | - # Windows installer ---------------------------------------------------- |
118 | | - # --------------------------------------------------------------------- |
119 | 103 | - name: Install PowerShell (Windows) |
120 | 104 | if: runner.os == 'Windows' |
121 | 105 | id: windows |
@@ -152,22 +136,3 @@ runs: |
152 | 136 | Invoke-WebRequest $url -OutFile $msi |
153 | 137 | Start-Process msiexec.exe -ArgumentList "/i", $msi, "/quiet", "/norestart" -Wait |
154 | 138 | } |
155 | | -
|
156 | | - $pwshPath = (Get-Command pwsh).Source |
157 | | - echo "PWSH_PATH=$pwshPath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
158 | | - echo "PWSH_VERSION=$($env:REQUESTED_VERSION)" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append |
159 | | - echo "pwsh-path=$pwshPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append |
160 | | - echo "pwsh-version=$($env:REQUESTED_VERSION)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append |
161 | | -
|
162 | | - # --------------------------------------------------------------------- |
163 | | - # Aggregate outputs ---------------------------------------------------- |
164 | | - # --------------------------------------------------------------------- |
165 | | - - name: Export composite outputs |
166 | | - id: export |
167 | | - shell: bash |
168 | | - run: | |
169 | | - echo "pwsh-path=$PWSH_PATH" >> $GITHUB_OUTPUT |
170 | | - echo "pwsh-version=$PWSH_VERSION" >> $GITHUB_OUTPUT |
171 | | - env: |
172 | | - PWSH_PATH: ${{ env.PWSH_PATH }} |
173 | | - PWSH_VERSION: ${{ env.PWSH_VERSION }} |
0 commit comments