Uh oh!
There was an error while loading. Please reload this page.
🩹 [Patch]: Ensure the selected GitHub module version is the one loaded - #100
🩹 [Patch]: Ensure the selected GitHub module version is the one loaded#100Marius Storhaug (MariusStorhaug) wants to merge 5 commits into
Conversation
…sions init.ps1 now resolves the exact installed version satisfying the Version input, removes any already-loaded GitHub module versions from the session, and imports the resolved version with -RequiredVersion -Global — so the user script uses the selected version instead of whatever PowerShell would auto-load from PSModulePath.
There was a problem hiding this comment.
Pull request overview
This PR makes the GitHub PowerShell module import deterministic by resolving an installed version that matches the requested Version input, unloading any already-loaded GitHub module, and then importing the resolved version with -RequiredVersion so subsequent scripts in the action run against the intended module version.
Changes:
- Resolve the newest installed GitHub module version that satisfies the requested
Versionconstraint. - Remove any already-loaded GitHub module from the session before importing.
- Import the resolved version explicitly via
Import-Module -RequiredVersion ... -Force -Global.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…loaded instances Per PR review: resolution now excludes prerelease versions when Prerelease is false and adds a stable-wins tie-breaker (so a Prerelease:false run never imports an installed prerelease, and stable wins at equal base version); and 'Get-Module -Name \ -All | Remove-Module' removes every loaded instance before import.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…r error Filter/sort on the 'Prerelease' string instead of IsPrerelease; add -ErrorAction Stop to the final Import-Module so a failed load stops the run; and render 'latest' in the throw message when no Version was requested (matching the moduleStatus display).
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…stable request When Prerelease is false, exclude prereleases from the already-installed check so a machine with only prerelease builds installed still installs a stable version instead of failing resolution.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…matches Normalize the already-installed set to \ when the (prerelease-filtered) query returns nothing, so the '-not' install guard and the '\ -ne' moduleStatus check both retain their original meaning instead of an empty array reading as 'installed'.
Makes the GitHub module version selected through the
Version/Prereleaseinputs the version that is actually installed, loaded, and used by the script.Fixed: the selected GitHub module version is the one loaded
init.ps1now:Prerelease— aPrerelease: falserun never resolves to an installed prerelease, with a stable-wins tie-breaker at equal base version (uses the PSResourceGetPrereleasestring).Get-Module -Name $Name -All | Remove-Module) so no side-by-side version remains.-RequiredVersion … -Force -Global -ErrorAction Stop, so every subsequent command (info.ps1, the user script,clean.ps1) uses the selected version and a failed load stops the run.Previously
init.ps1skipped importing when any version was already loaded and used an unconstrainedImport-Module, so PowerShell could auto-load a different (for example newer, preinstalled) version, defeating the requested pin.Technical Details
src/init.ps1: prerelease-aware resolution, remove-all-instances,-RequiredVersion/-Global/-ErrorAction Stopimport, and a clearer error (renderslatestwhen no version was requested).