natescherer / publish-powershell-action

A GitHub Action to publish a PowerShell module or script to GitHub Packages, a NuGet repository, or the PowerShell Gallery.
MIT License
11 stars 4 forks source link

Logic bug checking PowerShellGet version? #25

Open rmbolger opened 11 months ago

rmbolger commented 11 months ago

Hey there. Was just perusing the code and spotted what looks like a potential logic goof in this section.

https://github.com/natescherer/publish-powershell-action/blob/2808e8d968cb03e54d30f0a06a72ee2849b7d372/src/steps/2_prepare.ps1#L6C1-L15C2

If the idea is to ensure the existing module version is at least 2.2.5, shouldn't the operator be -lt rather than -ge or flip the corresponding blocks around?

I'm also curious if you need the -ListAvailable switch in the Get-Module call like you have further down when checking for PSResourceGet. Or do you not because it's already pre-imported by the action?

natescherer commented 10 months ago

Sorry for the delay in response!

You're absolutey right that the logic is borked here. I'll get that fixed to -lt in the next release. Never caught this because this is honestly just to account for an edge case where someone is using this action on a Windows self-hosted runner with only Windows PowerShell 5.1 installed, as that's the only situation where PSG will ever be less than 2.2.5.

As far as using -ListAvailable, that's not necessary because the act of calling Get-Module is going to load PowerShellGet if it isn't already loaded.