PaperCutExamples icon indicating copy to clipboard operation
PaperCutExamples copied to clipboard

The do-we-need-to-upgrade.ps1 script doesn't pull the correct Major version

Open turpie opened this issue 2 years ago • 2 comments

The do-we-need-to-upgrade.ps1 is notifying us of updates to old PaperCut major versions.

PS C:\scripts> . 'C:\scripts\do-we-need-to-upgrade.ps1'
Got the API Key!
Latest PaperCut release is 20.1.9. Installed Release is 22.1.4
PaperCut  20.1.9 already checked. Nothing to do here

How can we query for updates applicable to just the Major version that we are currently on? And later Major versions?

turpie avatar Oct 10 '23 01:10 turpie

I fixed it on our site by changing:

$CURRENT_RELEASE = [System.Version]((Invoke-RestMethod -uri http://www.papercut.com/products/mf/release-history.atom).id[0]  `
        -replace "^tag:papercut.com,[0-9]+-[0-9]+-[0-9]+:$PRODUCT\/releases\/v(\d+)-(\d+)-(\d+)", '$1.$2.$3')

to:

$releases = Invoke-RestMethod -uri http://www.papercut.com/products/mf/release-history.atom
$releases |ForEach-Object {
        $version = [System.Version]$_.id.Split('/v')[-1].Replace('-','.')
        if($version -gt $latest.version){
            $latest = $_
            $latest | Add-Member -MemberType NoteProperty -Name "version" -Value $version
        }
}
$CURRENT_RELEASE = $latest.version

turpie avatar Oct 10 '23 04:10 turpie

Looks like the original version didn’t take fixes to older releases into consideration. Would be worth creating a PR to get the change merged in.

Joffcom avatar Oct 10 '23 05:10 Joffcom