@@ -120,9 +120,16 @@ runs:
120120 # Debian/Ubuntu based
121121 echo "Detected Debian/Ubuntu based system..."
122122 if [[ "$IS_PRERELEASE" == "true" ]]; then
123- # For prerelease versions, select the powershell-preview package
123+ # Prerelease .deb naming varies across releases:
124+ # Older: powershell-preview_7.4.0-preview.5-1.deb_amd64.deb
125+ # Newer: powershell_7.6.0-preview.6-1.deb_amd64.deb
126+ # Try powershell-preview_ first, then fall back to powershell_
124127 URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
125128 ' [.assets[] | select(.name | test("^powershell-preview_.*\\.deb_" + $arch + "\\.deb$"))] | .[0].browser_download_url // empty' )
129+ if [[ -z "$URL" ]]; then
130+ URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
131+ ' [.assets[] | select(.name | test("^powershell_.*\\.deb_" + $arch + "\\.deb$"))] | .[0].browser_download_url // empty' )
132+ fi
126133 else
127134 # For stable versions, select the powershell package (not powershell-lts or powershell-preview)
128135 URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
@@ -147,8 +154,16 @@ runs:
147154 # RHEL/Fedora/CentOS based
148155 echo "Detected RHEL/Fedora/CentOS based system..."
149156 if [[ "$IS_PRERELEASE" == "true" ]]; then
157+ # Prerelease .rpm naming varies across releases:
158+ # Older: powershell-preview-7.4.0_preview.5-1.rh.x86_64.rpm
159+ # Newer: powershell-7.6.0_preview.6-1.rh.x86_64.rpm
160+ # Try powershell-preview first, then fall back to powershell-<version>
150161 URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
151162 ' [.assets[] | select(.name | test("^powershell-preview.*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty' )
163+ if [[ -z "$URL" ]]; then
164+ URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
165+ ' [.assets[] | select(.name | test("^powershell-[0-9].*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty' )
166+ fi
152167 else
153168 URL=$(echo "$RELEASE_JSON" | jq -r --arg arch "$ARCH" \
154169 ' [.assets[] | select(.name | test("^powershell-[0-9].*\\.rh\\." + (if $arch == "aarch64" then $arch else "x86_64" end) + "\\.rpm$"))] | .[0].browser_download_url // empty' )
@@ -172,6 +187,19 @@ runs:
172187 exit 1
173188 fi
174189
190+ # Determine the install directory and add to PATH before verification.
191+ # Preview builds install to /opt/microsoft/powershell/<major>-preview/
192+ # which is not on the default PATH after removing the old powershell package.
193+ MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
194+ if [[ "$IS_PRERELEASE" == "true" ]]; then
195+ INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}-preview"
196+ else
197+ INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}"
198+ fi
199+ if [[ -d "$INSTALL_DIR" ]]; then
200+ export PATH="$INSTALL_DIR:$PATH"
201+ fi
202+
175203 # Verify installation succeeded
176204 INSTALLED_VERSION=$(pwsh -NoLogo -NoProfile -Command '$PSVersionTable.PSVersion.ToString()' 2>/dev/null || true)
177205 if [[ "$INSTALLED_VERSION" != "$REQUESTED_VERSION" ]]; then
@@ -182,17 +210,9 @@ runs:
182210
183211 # For prerelease builds, add the install directory to GITHUB_PATH so subsequent
184212 # `shell: pwsh` steps resolve to the version we just installed.
185- if [[ "$REQUESTED_VERSION" == *-* ]]; then
186- MAJOR_VERSION=$(echo "$REQUESTED_VERSION" | cut -d'.' -f1)
187- if [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]]; then
188- INSTALL_DIR="/opt/microsoft/powershell/${MAJOR_VERSION}-preview"
189- if [[ -d "$INSTALL_DIR" ]]; then
190- echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
191- echo "$INSTALL_DIR" >> "$GITHUB_PATH"
192- fi
193- else
194- echo "Warning : Computed MAJOR_VERSION ('$MAJOR_VERSION') is invalid; skipping GITHUB_PATH update." >&2
195- fi
213+ if [[ "$IS_PRERELEASE" == "true" && -d "$INSTALL_DIR" ]]; then
214+ echo "Adding install directory to GITHUB_PATH : $INSTALL_DIR"
215+ echo "$INSTALL_DIR" >> "$GITHUB_PATH"
196216 fi
197217
198218 - name : Install PowerShell (macOS)
0 commit comments