Skip to content

🚀 [Feature]: Support installing prerelease PowerShell versions#16

Merged
Marius Storhaug (MariusStorhaug) merged 13 commits intomainfrom
feature/prerelease-support
Feb 17, 2026
Merged

🚀 [Feature]: Support installing prerelease PowerShell versions#16
Marius Storhaug (MariusStorhaug) merged 13 commits intomainfrom
feature/prerelease-support

Conversation

@MariusStorhaug
Copy link
Member

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Feb 17, 2026

The action now supports installing prerelease PowerShell versions (e.g. 7.4.0-preview.5, 7.5.0-rc.1) on all platforms. You can install a specific prerelease version by passing the full version string, or install the latest prerelease by setting the new Prerelease input to true.

New Prerelease input

A new Prerelease boolean input has been added, following the same UX pattern as Install-PSResource -Prerelease. When set to true and Version is latest, the action resolves to the latest prerelease from the PowerShell/PowerShell GitHub releases.

Usage Version Prerelease Result
Latest stable latest (default) false (default) Resolves to latest stable via /releases/latest
Latest prerelease latest true Resolves to latest prerelease via /releases API
Specific stable 7.5.0 Installs 7.5.0 directly
Specific prerelease 7.4.0-preview.5 Installs 7.4.0-preview.5 directly (no flag needed)

Installing the latest prerelease

- uses: PSModule/Install-PowerShell@v1
  with:
    Prerelease: true

Installing a specific prerelease version

- uses: PSModule/Install-PowerShell@v1
  with:
    Version: 7.4.0-preview.5

Linux package conflict handling

On Linux, the PowerShell project publishes multiple .deb variants (powershell, powershell-lts, powershell-preview) that all provide /usr/bin/pwsh and conflict with each other. The action now:

  • Uses specific asset name filters (powershell_ for stable, powershell-preview_ for prerelease) instead of a broad regex that could match the wrong package variant (e.g. powershell-lts instead of powershell)
  • Removes all existing PowerShell packages before installing to avoid dpkg conflicts when switching versions
  • Verifies the installed version matches the requested version after install, failing early with a clear error if not
  • Applies the same fixes for RPM-based distributions

Windows prerelease handling

On Windows, preview builds install to $env:ProgramFiles\PowerShell\7-preview\ instead of $env:ProgramFiles\PowerShell\7\. The action now correctly handles:

  • Downgrade detection by stripping the prerelease suffix before [version] comparison (Windows PowerShell 5.1 lacks [semver])
  • Uninstall registry filtering to match Preview display names when the current version is a preview
  • Cross-prerelease version changes (same base version, different label) by forcing an uninstall-then-install cycle

PATH management

After installation, the action adds the PowerShell install directory to GITHUB_PATH on all platforms. This ensures subsequent workflow steps using shell: pwsh resolve to the newly installed version — including preview builds whose install directory is not on the runner's default PATH.

- Update action input description to document prerelease version support
- Fix Windows downgrade detection to handle prerelease version strings
  by stripping the prerelease suffix before casting to [version]
- Fix Windows uninstall registry filter to match Preview display names
  when uninstalling a preview build
- Add prerelease version (7.6.0-preview.6) to test workflow matrix
- Update test verification to detect preview installs on Windows
  (preview builds install to a separate directory)
- Update README with prerelease documentation and usage example

Closes #15
Copilot AI review requested due to automatic review settings February 17, 2026 09:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for installing specific prerelease PowerShell versions (e.g. 7.6.0-preview.6, 7.5.0-rc.1) by allowing users to pass the exact prerelease string via the existing Version input, plus updates docs and CI coverage to reflect prerelease behavior.

Changes:

  • Document prerelease version support in action.yml and README.md.
  • Update Windows downgrade/uninstall logic to better handle prerelease version strings.
  • Extend the CI workflow matrix and verification logic to include a prerelease version on Windows.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
action.yml Documents prerelease input; adjusts Windows downgrade detection and uninstall registry filtering for preview/rc installs.
README.md Adds prerelease support notes and a prerelease usage example; updates input docs.
.github/workflows/Action-Test.yml Adds a prerelease to the test matrix and updates version verification for Windows preview installs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add 'Prerelease' boolean input (default: false), similar to
  Install-PSResource's -Prerelease switch
- When Prerelease is true and Version is 'latest', resolve to the latest
  prerelease from the PowerShell/PowerShell GitHub releases API
- Explicit prerelease version strings (e.g. 7.6.0-preview.6) continue to
  work directly without the Prerelease flag
- Add prerelease resolution to all 3 platform steps (Linux bash, macOS
  bash, Windows PowerShell 5.1)
- Update test workflow with 'prerelease' matrix entry
- Update README with Prerelease input docs and latest prerelease example
…to GITHUB_PATH

After MSI install on Windows, the running shell may still resolve the
pre-installed pwsh from PATH. Two fixes:

1. action.yml: Append the install directory to GITHUB_PATH so that
   subsequent 'shell: pwsh' steps in the consumer's workflow resolve to
   the version we just installed (critical for preview builds whose
   7-preview dir is not on the runner's default PATH, but also defensive
   for stable upgrades).

2. Action-Test.yml: Verification step now always launches pwsh from the
   known install directory on Windows (both stable and prerelease),
   instead of relying on $PSVersionTable from the current shell.
Copilot AI review requested due to automatic review settings February 17, 2026 10:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add null/empty checks for prerelease resolution on all 3 platforms
  (Linux jq // empty + bash validation, macOS same, Windows null check)
- Fix prerelease downgrade detection: force uninstall when same base
  version but different prerelease labels (MSI can't handle in-place)
- Fix inconsistent regex escaping: -preview|-rc (not -preview|\-rc)
- Fix StartsWith over-matching in registry filter: use regex with
  delimiter-aware boundary instead of string prefix match
- Extract major version dynamically for install path (not hardcoded 7)
- Add GITHUB_PATH updates for Linux/macOS preview builds
- Add null check in test workflow prerelease resolution
The GITHUB_PATH writes add known hardcoded install directories
(not user-controlled input), so the github-env audit is a false
positive. Add inline zizmor: ignore[github-env] comments on all
three platform run: blocks.
Copilot AI review requested due to automatic review settings February 17, 2026 10:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings February 17, 2026 11:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Validate MAJOR_VERSION is digits-only before writing to GITHUB_PATH (Linux, macOS, Windows)
- Add per_page=100 to /releases API calls when resolving latest prerelease (Linux, macOS, Windows)
Copilot AI review requested due to automatic review settings February 17, 2026 11:25
@MariusStorhaug
Copy link
Member Author

Addressed all 6 unresolved review comments in commit ad4035f:

GITHUB_PATH env-file injection (3 comments)

  • Linux (L134): Added [[ "$MAJOR_VERSION" =~ ^[0-9]+$ ]] validation before writing to GITHUB_PATH
  • macOS (L229): Same digits-only validation added
  • Windows (L400): Added $majorVersion -match '^\d+$' validation before writing to GITHUB_PATH

Prerelease API pagination (3 comments)

  • Linux: Added ?per_page=100 to /releases API call
  • macOS (L164): Added ?per_page=100 to /releases API call
  • Windows (L257): Added ?per_page=100 to Invoke-RestMethod URI

Used per_page=100 instead of full pagination logic — PowerShell/PowerShell always has the latest prerelease within the most recent 100 releases, and this avoids unnecessary complexity.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The PowerShell release naming convention changed over time (e.g.
powershell-preview_ vs powershell_ prefix for .deb packages).
Instead of hardcoding the package filename pattern, query the
GitHub Releases API for the actual asset URLs. This handles all
historical and future naming conventions correctly.
Copilot AI review requested due to automatic review settings February 17, 2026 11:38
…fic package name filters

- Use specific jq filters (powershell_ for stable, powershell-preview_ for prerelease) instead of broad ^powershell.* regex that could match powershell-lts
- Remove existing conflicting PowerShell packages (powershell, powershell-lts, powershell-preview) before dpkg/rpm install to avoid /usr/bin/pwsh conflicts
- Add post-install verification to fail early if the installed version does not match the requested version
- Apply same fixes for RPM-based distributions
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

action.yml:272

  • Same YAML issue here: run: followed by an indented | ... line is not valid for a multiline script. This needs to be run: | (optionally with the zizmor comment) or the action definition won’t parse.
        esac

        URL="https://github.com/PowerShell/PowerShell/releases/download/v${REQUESTED_VERSION}/${PKG_NAME}"
        echo "Downloading from: $URL"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Prerelease .deb naming changed between releases:
  Older (7.4.x): powershell-preview_7.4.0-preview.5-1.deb_amd64.deb
  Newer (7.6.x): powershell_7.6.0-preview.6-1.deb_amd64.deb
  Now tries powershell-preview_ first, falls back to powershell_
- Same fallback logic applied for .rpm assets
- Fix verification failure for preview installs: preview builds install to
  /opt/microsoft/powershell/<major>-preview/ which is not on PATH after
  removing the old stable package. Now adds install dir to PATH before
  running verification.
- Simplified GITHUB_PATH update using the IS_PRERELEASE flag already computed
@MariusStorhaug Marius Storhaug (MariusStorhaug) merged commit fae8569 into main Feb 17, 2026
32 checks passed
@MariusStorhaug Marius Storhaug (MariusStorhaug) deleted the feature/prerelease-support branch February 17, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🚀 [Feature]: Support installing prerelease PowerShell versions

1 participant