Skip to content

update.ps1.html

Tunisiano18 edited this page Sep 12, 2024 · 18 revisions

function global:au_BeforeUpdate {
	. ..\..\scripts\Get-FileVersion.ps1
	$FileVersion = Get-FileVersion $Latest.URL32
	$Latest.Checksum32 = $FileVersion.Checksum
	$Latest.ChecksumType32 = $FileVersion.checksumType
}

and

        ".\tools\VERIFICATION.txt" = @{
          "(?i)(\s+x64:).*"                   = "`${1} $($Latest.URL64)"
          "(?i)(Get-RemoteChecksum).*"        = "`${1} $($Latest.URL64)"
          "(?i)(\s+checksum64:).*"            = "`${1} $($Latest.Checksum64)"
        }

Replace line

(Get-Content $NuspecPath) -replace '<version>.*',"<version>0.0</version>" | Set-Content $NuspecPath

Release Notes update

		"$($Latest.PackageName).nuspec" = @{
			"(\<releaseNotes\>).*?(\</releaseNotes\>)"		= "`${1}$($Latest.ReleaseNotes)`$2"
			"(\<copyright\>).*?(\</copyright\>)" 	= "`${1}IVPN.net $((Get-Date).year)`$2"
		}

and

$releaseNotes="https://github.com/$($Owner)/$($repo)/releases/tag/$($tags[0].tag_name)"
$Latest = @{ URL32 = $url32; Version = $version; ReleaseNotes = $releaseNotes }

For version not updating, check checksum

    $current_checksum = (Get-Item $PSScriptRoot\tools\chocolateyInstall.ps1 | Select-String '\bchecksum\b') -split "=|'" | Select-Object -Last 1 -Skip 1
    if ($current_checksum.Length -ne 64) { throw "Can't find current checksum" }
    $remote_checksum  = Get-RemoteChecksum $url
    if ($current_checksum -ne $remote_checksum) {
        Write-Host 'Remote checksum is different then the current one, forcing update'
        $global:au_old_force = $global:au_force
        $global:au_force = $true
    }

To exclude known updating errors

    try {
        update
    } catch {
        $ignore = "You cannot call a method on a null-valued expression."
        if ($_ -match $ignore) { Write-Output $ignore; 'ignore' } else { throw $_ }
    }

Get the version from a file

Clone this wiki locally