Skip to content

🩹 [Patch]: Ensure the selected GitHub module version is the one loaded#100

Open
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
fix/ensure-single-loaded-module-version
Open

🩹 [Patch]: Ensure the selected GitHub module version is the one loaded#100
Marius Storhaug (MariusStorhaug) wants to merge 1 commit into
mainfrom
fix/ensure-single-loaded-module-version

Conversation

@MariusStorhaug

Copy link
Copy Markdown
Member

Makes the GitHub module version selected through the Version/Prerelease inputs the version that is actually loaded and used by the script. Previously init.ps1 skipped importing whenever any version was already loaded, and when it did import it used an unconstrained Import-Module — so PowerShell could auto-load a different (for example newer, preinstalled) version from PSModulePath, defeating the requested pin.

Fixed: the selected GitHub module version is the one loaded

init.ps1 now resolves the exact installed version satisfying the request, removes any already-loaded GitHub module versions from the session, and imports the resolved version with -RequiredVersion … -Force -Global. Every subsequent command in the run (info.ps1, the user script, clean.ps1) uses the selected version.

Technical Details

  • src/init.ps1: resolve the newest installed version matching Version via Get-InstalledPSResource; Remove-Module -Force before importing; Import-Module -RequiredVersion <resolved> -Force -Global. Fails fast if no installed version satisfies the requested Version.
  • No input or interface changes.

…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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 Version constraint.
  • 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.

Comment thread src/init.ps1
Comment on lines +70 to +82
# Resolve the exact installed version that satisfies the request (newest match), so the loaded
# module is deterministic instead of whatever PowerShell would auto-load from PSModulePath.
$resolveParams = @{
Name = $Name
ErrorAction = 'SilentlyContinue'
}
if ($Version) {
$resolveParams['Version'] = $Version
}
$resolved = Get-InstalledPSResource @resolveParams | Sort-Object Version -Descending | Select-Object -First 1
if (-not $resolved) {
throw "No installed '$Name' version satisfies the requested version '$Version'."
}
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.

2 participants