Skip to content

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

Open
Marius Storhaug (MariusStorhaug) wants to merge 5 commits 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 5 commits into
mainfrom
fix/ensure-single-loaded-module-version

Conversation

@MariusStorhaug

@MariusStorhaug Marius Storhaug (MariusStorhaug) commented Jul 11, 2026

Copy link
Copy Markdown
Member

Makes the GitHub module version selected through the Version/Prerelease inputs the version that is actually installed, loaded, and used by the script.

Fixed: the selected GitHub module version is the one loaded

init.ps1 now:

  • Resolves the exact installed version satisfying the request, honoring Prerelease — a Prerelease: false run never resolves to an installed prerelease, with a stable-wins tie-breaker at equal base version (uses the PSResourceGet Prerelease string).
  • Removes every already-loaded instance (Get-Module -Name $Name -All | Remove-Module) so no side-by-side version remains.
  • Imports the resolved version with -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.ps1 skipped importing when any version was already loaded and used an unconstrained Import-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 Stop import, and a clearer error (renders latest when no version was requested).
  • 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

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

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

Comment thread src/init.ps1
Comment thread src/init.ps1 Outdated
…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.

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

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

Comment thread src/init.ps1 Outdated
Comment thread src/init.ps1 Outdated
…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).

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comment thread src/init.ps1

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

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

Comment thread src/init.ps1
Comment thread src/init.ps1
…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.

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

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

Comment thread src/init.ps1
Comment thread src/init.ps1
…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'.

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

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