forked from steviecoaster/automaticpackages
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUniversal.ps1
34 lines (26 loc) · 1.8 KB
/
Universal.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[cmdletBinding()]
param(
[Parameter()]
[Version]
$DashboardVersion = $([string](Invoke-WebRequest -UseBasicParsing 'https://imsreleases.blob.core.windows.net/universal/production/version.txt')),
[Parameter()]
[String]
$DashboardDownloadPath = "https://imsreleases.blob.core.windows.net/universal/production/$dashboardVersion/PowerShellUniversal.$dashboardVersion.msi",
[Parameter()]
[string]
$Checksum = $([string](Invoke-WebRequest -UseBasicParsing "https://imsreleases.blob.core.windows.net/universal/production/$dashboardVersion/PowerShellUniversal.$dashboardVersion.msi.sha256"))
)
$currentVersion = choco list powershelluniversal --exact -r | ConvertFrom-CSV -Delimiter '|' -Header 'Name', 'Version'
if($null -eq $currentVersion) {
$currentVersion = [pscustomobject]@{'Version' = '0.0.0'}
}
if ([version]$($currentVersion.Version) -lt $DashboardVersion) {
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$Nuspec = Get-ChildItem $toolsDir -recurse -filter powershelluniversal.nuspec | Select-Object -ExpandProperty FullName
$Install = Get-ChildItem $toolsDir -Recurse -Filter 'chocolateyInstall.ps1' | Where-Object { $_.Directory -notmatch 'powershelluniversal.licensed|zulip' } | Select-Object -ExpandProperty FullName
(Get-Content "$Install").Replace('[[URL]]', "$DashboardDownloadPath") | Set-Content "$Install"
(Get-Content "$Install").Replace('[[CHECKSUM]]', "$($Checksum.Trim())") | Set-Content "$Install"
(Get-Content "$Nuspec").Replace('[[VERSION]]', "$DashboardVersion") | Set-Content "$Nuspec"
choco pack $Nuspec --output-directory="'$toolsDir'"
choco push $((Get-ChildItem $toolsDir -filter powrshelluniversal.*.nupkg).FullName) -s https://push.chocolatey.org --api-key="'$env:ChocolateyKey'"
}