Skip to content

Commit

Permalink
Install - Correct and allow choco package script to run from release …
Browse files Browse the repository at this point in the history
…(root repo) script and use local binaries
  • Loading branch information
Liryna committed Feb 3, 2024
1 parent 8606d41 commit fbbcc3d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
34 changes: 14 additions & 20 deletions chocolatey/package.ps1
Original file line number Diff line number Diff line change
@@ -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
8 changes: 3 additions & 5 deletions chocolatey/release.ps1
Original file line number Diff line number Diff line change
@@ -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/"
12 changes: 5 additions & 7 deletions scripts/build_installer.ps1 → scripts/build_and_release.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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" }

0 comments on commit fbbcc3d

Please sign in to comment.