Skip to content

Commit ef2858c

Browse files
Implement Linux and macOS support
1 parent 222c5d3 commit ef2858c

File tree

1 file changed

+48
-18
lines changed

1 file changed

+48
-18
lines changed

action.yml

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,24 +32,39 @@ runs:
3232
working-directory: ${{ github.action_path }}
3333
env:
3434
REQUESTED_VERSION: ${{ inputs.Version }}
35+
PREVIEW: ${{ inputs.Preview }}
3536
GITHUB_TOKEN: ${{ github.token }}
3637
run: |
3738
# Install-PowerShell
3839
set -e
3940
echo "Requested version: [$REQUESTED_VERSION]"
41+
echo "Preview mode: [$PREVIEW]"
4042
4143
# Only resolve to latest version if explicitly set to 'latest' (case-insensitive)
4244
case "${REQUESTED_VERSION:-}" in
4345
[Ll][Aa][Tt][Ee][Ss][Tt])
44-
REQUESTED_VERSION=$(
45-
curl -s -f \
46-
-H "Accept: application/vnd.github+json" \
47-
-H "Authorization: Bearer $GITHUB_TOKEN" \
48-
-H "X-GitHub-Api-Version: 2022-11-28" \
49-
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
50-
jq -r '.tag_name' | sed 's/^v//'
51-
)
52-
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
46+
if [[ "${PREVIEW,,}" == "true" ]]; then
47+
echo "Fetching latest preview release..."
48+
REQUESTED_VERSION=$(
49+
curl -s -f \
50+
-H "Accept: application/vnd.github+json" \
51+
-H "Authorization: Bearer $GITHUB_TOKEN" \
52+
-H "X-GitHub-Api-Version: 2022-11-28" \
53+
https://api.github.com/repos/PowerShell/PowerShell/releases |
54+
jq -r '[.[] | select(.prerelease == true)] | .[0].tag_name' | sed 's/^v//'
55+
)
56+
echo "Latest preview PowerShell release detected: $REQUESTED_VERSION"
57+
else
58+
REQUESTED_VERSION=$(
59+
curl -s -f \
60+
-H "Accept: application/vnd.github+json" \
61+
-H "Authorization: Bearer $GITHUB_TOKEN" \
62+
-H "X-GitHub-Api-Version: 2022-11-28" \
63+
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
64+
jq -r '.tag_name' | sed 's/^v//'
65+
)
66+
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
67+
fi
5368
;;
5469
"")
5570
echo "Error: Version input is required (or use 'latest')"
@@ -106,24 +121,39 @@ runs:
106121
working-directory: ${{ github.action_path }}
107122
env:
108123
REQUESTED_VERSION: ${{ inputs.Version }}
124+
PREVIEW: ${{ inputs.Preview }}
109125
GITHUB_TOKEN: ${{ github.token }}
110126
run: |
111127
# Install-PowerShell
112128
set -e
113129
echo "Requested version: [$REQUESTED_VERSION]"
130+
echo "Preview mode: [$PREVIEW]"
114131
115132
# Only resolve to latest version if explicitly set to 'latest' (case-insensitive)
116133
case "${REQUESTED_VERSION:-}" in
117134
[Ll][Aa][Tt][Ee][Ss][Tt])
118-
REQUESTED_VERSION=$(
119-
curl -s -f \
120-
-H "Accept: application/vnd.github+json" \
121-
-H "Authorization: Bearer $GITHUB_TOKEN" \
122-
-H "X-GitHub-Api-Version: 2022-11-28" \
123-
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
124-
jq -r '.tag_name' | sed 's/^v//'
125-
)
126-
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
135+
if [[ "${PREVIEW,,}" == "true" ]]; then
136+
echo "Fetching latest preview release..."
137+
REQUESTED_VERSION=$(
138+
curl -s -f \
139+
-H "Accept: application/vnd.github+json" \
140+
-H "Authorization: Bearer $GITHUB_TOKEN" \
141+
-H "X-GitHub-Api-Version: 2022-11-28" \
142+
https://api.github.com/repos/PowerShell/PowerShell/releases |
143+
jq -r '[.[] | select(.prerelease == true)] | .[0].tag_name' | sed 's/^v//'
144+
)
145+
echo "Latest preview PowerShell release detected: $REQUESTED_VERSION"
146+
else
147+
REQUESTED_VERSION=$(
148+
curl -s -f \
149+
-H "Accept: application/vnd.github+json" \
150+
-H "Authorization: Bearer $GITHUB_TOKEN" \
151+
-H "X-GitHub-Api-Version: 2022-11-28" \
152+
https://api.github.com/repos/PowerShell/PowerShell/releases/latest |
153+
jq -r '.tag_name' | sed 's/^v//'
154+
)
155+
echo "Latest stable PowerShell release detected: $REQUESTED_VERSION"
156+
fi
127157
;;
128158
"")
129159
echo "Error: Version input is required (or use 'latest')"

0 commit comments

Comments
 (0)