Skip to content

Commit fbbcc3d

Browse files
committed
Install - Correct and allow choco package script to run from release (root repo) script and use local binaries
1 parent 8606d41 commit fbbcc3d

File tree

3 files changed

+22
-32
lines changed

3 files changed

+22
-32
lines changed

chocolatey/package.ps1

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,31 @@
1-
param($ver)
1+
param($version)
22

33
$ErrorActionPreference = 'Stop'
44

5-
Remove-Item build -Recurse -Force -ErrorAction SilentlyContinue
5+
Remove-Item .\chocolatey\build -Recurse -Force -ErrorAction SilentlyContinue
66

7-
New-Item ./build -Force -ItemType Directory
8-
Copy-Item dokany.nuspec.template build/dokany.nuspec
9-
Copy-Item tools build/ -Recurse
10-
Rename-Item build/tools/chocolateyinstall.ps1.template chocolateyinstall.ps1
7+
New-Item .\chocolatey\build -Force -ItemType Directory
8+
Copy-Item .\chocolatey\dokany.nuspec.template .\chocolatey\build\dokany.nuspec
9+
Copy-Item .\chocolatey\tools .\chocolatey\build\ -Recurse
10+
Rename-Item .\chocolatey\build\tools\chocolateyinstall.ps1.template chocolateyinstall.ps1
1111

12-
(Get-Content build/dokany.nuspec).Replace('[[PackageVersion]]', $ver) | Set-Content build/dokany.nuspec
13-
14-
$url64 = "https://github.com/dokan-dev/dokany/releases/download/v${ver}/Dokan_x64.msi"
15-
$url32 = "https://github.com/dokan-dev/dokany/releases/download/v${ver}/Dokan_x86.msi"
12+
(Get-Content -Encoding UTF8 .\chocolatey\build\dokany.nuspec).Replace('[[PackageVersion]]', $version) | Set-Content -Encoding UTF8 .\chocolatey\build\dokany.nuspec
1613

1714
function Hash {
1815
param (
19-
$url
16+
$path
2017
)
21-
Invoke-WebRequest $url -OutFile build/dokany.msi
22-
$hash = Get-FileHash build/dokany.msi -Algorithm SHA256
18+
$hash = Get-FileHash $path -Algorithm SHA256
2319
# return hex string
2420
return $hash.Hash
2521
}
2622

27-
$hash64 = Hash $url64
28-
$hash32 = Hash $url32
23+
$hash64 = Hash .\dokan_wix\Dokan_x64.msi
24+
$hash32 = Hash .\dokan_wix\Dokan_x86.msi
2925

30-
$install = (Get-Content build/tools/chocolateyinstall.ps1)
26+
$install = (Get-Content .\chocolatey\build\tools\chocolateyinstall.ps1)
3127
$install = $install.Replace('[[Url]]', $url32).Replace('[[Checksum]]', $hash32)
3228
$install = $install.Replace('[[Url64]]', $url64).Replace('[[Checksum64]]', $hash64)
33-
Set-Content build/tools/chocolateyinstall.ps1 -Value $install
29+
Set-Content -Encoding UTF8 .\chocolatey\build\tools\chocolateyinstall.ps1 -Value $install
3430

35-
Set-Location .\build
36-
choco pack
37-
Set-Location ..
31+
choco pack .\chocolatey\build\dokany.nuspec --out .\chocolatey\build

chocolatey/release.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
1-
param($ver)
1+
param($version)
22

33
$ErrorActionPreference = 'Stop'
44

5-
.\package.ps1 $ver
5+
.\chocolatey\package.ps1 $version
66

7-
Set-Location .\build
8-
choco push "dokany2.${ver}.nupkg" --api-key="${CHOCO_API_KEY}" --source="https://push.chocolatey.org/"
9-
Set-Location ..
7+
choco push ".\chocolatey\build\dokany2.${version}.nupkg" --api-key="${CHOCO_API_KEY}" --source="https://push.chocolatey.org/"
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ $ErrorActionPreference = "Stop"
44

55
Add-VisualStudio-Path
66

7-
# This powershell script need SIGNTOOL and EV_CERTTHUMBPRINT env variable set
7+
# This powershell script need SIGNTOOL, EV_CERTTHUMBPRINT and CHOCO_API_KEY env variable set
88
# SIGNTOOL - Signtool path
99
# EV_CERTTHUMBPRINT - EV Sign certificat thumb print
10+
# CHOCO_API_KEY - Chocolatey API key to publish new installers
1011

1112
Write-Host Set Dokan version ...
1213
if (!(Test-Path -Path .\dokan_wix\SetAssemblyVersion\bin\Release\SetAssemblyVersion.exe)) {
@@ -52,15 +53,12 @@ set-alias sz "$env:ProgramFiles\7-Zip\7z.exe"
5253
Exec-External { sz a -tzip .\dokan_wix\dokan.zip Win32 x64 ARM ARM64 }
5354
Write-Host Build archive done !
5455

55-
if ([string]::IsNullOrEmpty($env:CHOCO_PUBLISH_API_KEY)) {
56-
Write-Host Skip Chocolatey publication due to missing CHOCO_PUBLISH_API_KEY env variable
56+
if ([string]::IsNullOrEmpty($env:CHOCO_API_KEY)) {
57+
Write-Host Skip Chocolatey publication due to missing CHOCO_API_KEY env variable
5758
exit
5859
}
5960
$publishChocoConfirmation = Read-Host "Do you want to publish version ${version} to Chocolatey ? [y/n]"
6061
if ($publishChocoConfirmation -ne 'y') { exit }
6162
$baseVersion = Select-String -Path .\dokan_wix\version.xml -Pattern 'BaseVersion="(.*)"' | % { $_.Matches.groups[1].Value }
6263
$buildVersion = Select-String -Path .\dokan_wix\version.xml -Pattern 'BuildVersion="(.*)"' | % { $_.Matches.groups[1].Value }
63-
Push-Location .\chocolatey
64-
Exec-External { .\release.ps1 "$baseVersion.$buildVersion" }
65-
Pop-Location
66-
64+
Exec-External { .\chocolatey\release.ps1 "$baseVersion.$buildVersion" }

0 commit comments

Comments
 (0)