From fbbcc3d6af704ecb6fddd170c5552274863cf435 Mon Sep 17 00:00:00 2001 From: Liryna Date: Sat, 3 Feb 2024 18:44:37 -0500 Subject: [PATCH] Install - Correct and allow choco package script to run from release (root repo) script and use local binaries --- chocolatey/package.ps1 | 34 ++++++++----------- chocolatey/release.ps1 | 8 ++--- ...ld_installer.ps1 => build_and_release.ps1} | 12 +++---- 3 files changed, 22 insertions(+), 32 deletions(-) rename scripts/{build_installer.ps1 => build_and_release.ps1} (88%) diff --git a/chocolatey/package.ps1 b/chocolatey/package.ps1 index d6400df7..7e7ce128 100644 --- a/chocolatey/package.ps1 +++ b/chocolatey/package.ps1 @@ -1,37 +1,31 @@ -param($ver) +param($version) $ErrorActionPreference = 'Stop' -Remove-Item build -Recurse -Force -ErrorAction SilentlyContinue +Remove-Item .\chocolatey\build -Recurse -Force -ErrorAction SilentlyContinue -New-Item ./build -Force -ItemType Directory -Copy-Item dokany.nuspec.template build/dokany.nuspec -Copy-Item tools build/ -Recurse -Rename-Item build/tools/chocolateyinstall.ps1.template chocolateyinstall.ps1 +New-Item .\chocolatey\build -Force -ItemType Directory +Copy-Item .\chocolatey\dokany.nuspec.template .\chocolatey\build\dokany.nuspec +Copy-Item .\chocolatey\tools .\chocolatey\build\ -Recurse +Rename-Item .\chocolatey\build\tools\chocolateyinstall.ps1.template chocolateyinstall.ps1 -(Get-Content build/dokany.nuspec).Replace('[[PackageVersion]]', $ver) | Set-Content build/dokany.nuspec - -$url64 = "https://github.com/dokan-dev/dokany/releases/download/v${ver}/Dokan_x64.msi" -$url32 = "https://github.com/dokan-dev/dokany/releases/download/v${ver}/Dokan_x86.msi" +(Get-Content -Encoding UTF8 .\chocolatey\build\dokany.nuspec).Replace('[[PackageVersion]]', $version) | Set-Content -Encoding UTF8 .\chocolatey\build\dokany.nuspec function Hash { param ( - $url + $path ) - Invoke-WebRequest $url -OutFile build/dokany.msi - $hash = Get-FileHash build/dokany.msi -Algorithm SHA256 + $hash = Get-FileHash $path -Algorithm SHA256 # return hex string return $hash.Hash } -$hash64 = Hash $url64 -$hash32 = Hash $url32 +$hash64 = Hash .\dokan_wix\Dokan_x64.msi +$hash32 = Hash .\dokan_wix\Dokan_x86.msi -$install = (Get-Content build/tools/chocolateyinstall.ps1) +$install = (Get-Content .\chocolatey\build\tools\chocolateyinstall.ps1) $install = $install.Replace('[[Url]]', $url32).Replace('[[Checksum]]', $hash32) $install = $install.Replace('[[Url64]]', $url64).Replace('[[Checksum64]]', $hash64) -Set-Content build/tools/chocolateyinstall.ps1 -Value $install +Set-Content -Encoding UTF8 .\chocolatey\build\tools\chocolateyinstall.ps1 -Value $install -Set-Location .\build -choco pack -Set-Location .. +choco pack .\chocolatey\build\dokany.nuspec --out .\chocolatey\build diff --git a/chocolatey/release.ps1 b/chocolatey/release.ps1 index fcf43883..a432dcc5 100644 --- a/chocolatey/release.ps1 +++ b/chocolatey/release.ps1 @@ -1,9 +1,7 @@ -param($ver) +param($version) $ErrorActionPreference = 'Stop' -.\package.ps1 $ver +.\chocolatey\package.ps1 $version -Set-Location .\build -choco push "dokany2.${ver}.nupkg" --api-key="${CHOCO_API_KEY}" --source="https://push.chocolatey.org/" -Set-Location .. +choco push ".\chocolatey\build\dokany2.${version}.nupkg" --api-key="${CHOCO_API_KEY}" --source="https://push.chocolatey.org/" \ No newline at end of file diff --git a/scripts/build_installer.ps1 b/scripts/build_and_release.ps1 similarity index 88% rename from scripts/build_installer.ps1 rename to scripts/build_and_release.ps1 index 31edf44d..e5787a1a 100644 --- a/scripts/build_installer.ps1 +++ b/scripts/build_and_release.ps1 @@ -4,9 +4,10 @@ $ErrorActionPreference = "Stop" Add-VisualStudio-Path -# This powershell script need SIGNTOOL and EV_CERTTHUMBPRINT env variable set +# This powershell script need SIGNTOOL, EV_CERTTHUMBPRINT and CHOCO_API_KEY env variable set # SIGNTOOL - Signtool path # EV_CERTTHUMBPRINT - EV Sign certificat thumb print +# CHOCO_API_KEY - Chocolatey API key to publish new installers Write-Host Set Dokan version ... if (!(Test-Path -Path .\dokan_wix\SetAssemblyVersion\bin\Release\SetAssemblyVersion.exe)) { @@ -52,15 +53,12 @@ set-alias sz "$env:ProgramFiles\7-Zip\7z.exe" Exec-External { sz a -tzip .\dokan_wix\dokan.zip Win32 x64 ARM ARM64 } Write-Host Build archive done ! -if ([string]::IsNullOrEmpty($env:CHOCO_PUBLISH_API_KEY)) { - Write-Host Skip Chocolatey publication due to missing CHOCO_PUBLISH_API_KEY env variable +if ([string]::IsNullOrEmpty($env:CHOCO_API_KEY)) { + Write-Host Skip Chocolatey publication due to missing CHOCO_API_KEY env variable exit } $publishChocoConfirmation = Read-Host "Do you want to publish version ${version} to Chocolatey ? [y/n]" if ($publishChocoConfirmation -ne 'y') { exit } $baseVersion = Select-String -Path .\dokan_wix\version.xml -Pattern 'BaseVersion="(.*)"' | % { $_.Matches.groups[1].Value } $buildVersion = Select-String -Path .\dokan_wix\version.xml -Pattern 'BuildVersion="(.*)"' | % { $_.Matches.groups[1].Value } -Push-Location .\chocolatey -Exec-External { .\release.ps1 "$baseVersion.$buildVersion" } -Pop-Location - +Exec-External { .\chocolatey\release.ps1 "$baseVersion.$buildVersion" }