-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathNewVersionAvailable.ps1
37 lines (32 loc) · 1.41 KB
/
NewVersionAvailable.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
35
36
37
Param(
[string]$AlertRecipient,
[PSCredential]$Credentials
)
Push-Location
Set-Location $(Split-Path -Parent $MyInvocation.MyCommand.Definition)
$ErrorActionPreference = "Stop"
#Max Version Online
$maxVersion = $(
(New-Object System.Net.WebClient).DownloadString("http://download.virtualbox.org/virtualbox/") -split "`n" |
? {$_ -match "NAME=`"(\d+\.\d+\.\d+)/`""} |
% {[version]$Matches[1]} | Measure-Object -Maximum
).Maximum
$powershell = Get-Content .\tools\chocolateyInstall.ps1
$powershell[1] -match "\d+\.\d+\.\d+" | Out-Null
[version]$currentVersion = $Matches[0]
if ($currentVersion -lt $maxVersion)
{
$version = $maxVersion.ToString()
Send-MailMessage -To $AlertRecipient -Subject "Chocolatey-VBoxGuestAdditions" -Body "Version $version is available" -From $Credentials.UserName -SmtpServer smtp.mandrillapp.com -Port 587 -Credential $Credentials
$powershell[1] = "`$url = 'http://download.virtualbox.org/virtualbox/$version/VBoxGuestAdditions_$version.iso'"
Set-Content -Path .\tools\chocolateyInstall.ps1 -Value $powershell
[xml]$nuspec = Get-Content -Raw .\VBoxGuestAdditions.nuspec
$nuspec.package.metadata.version = $version.ToString()
$nuspecPath = ".\VBoxGuestAdditions.nuspec"
New-Item $nuspecPath -Force -ItemType File | Out-Null
$nuspecPath = Resolve-Path $nuspecPath
$nuspec.Save($nuspecPath)
iex "choco pack"
Write-Output $version
}
Pop-Location