-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-burnawarepremium.ps1
72 lines (58 loc) · 3.45 KB
/
build-burnawarepremium.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Write-Host "Building Chocolately Package for Burnaware Premium..."
Write-Host "Create Folders..."
New-Item -Path . -Name "temp" -ItemType "directory" -ErrorAction Ignore
New-Item -Path . -Name "burnawarepremium" -ItemType "directory" -ErrorAction Ignore
New-Item -Path .\burnawarepremium -Name "tools" -ItemType "directory" -ErrorAction Ignore
Write-Host "Getting current version..."
$currentversionurl = "www.burnaware.com/download.html"
$currentversion = Invoke-WebRequest -Uri $currentversionurl
$version = [regex]::match($currentversion.Content, "BurnAware Premium.*Version (.*?)<br />", [Text.RegularExpressions.RegexOptions]::Singleline).Groups[1].Value
Write-Host "Version: $version"
$url = [regex]::match($currentversion.Content, "BurnAware Premium.*?href=`"(.*?)`"", [Text.RegularExpressions.RegexOptions]::Singleline).Groups[1].Value
if ($url.StartsWith("/")) { $url = "https://www.burnaware.com" + $url }
Write-Host "Download Link: $url"
Write-Host "Downloading file to get the filehash..."
$whatsnewurl = "www.burnaware.com/whats-new.html"
$outfile = ".\temp\premium_$version"
Invoke-WebRequest -Uri $url -outfile $outfile
$filehash = (Get-FileHash $outfile).Hash
Write-Host "File hash: $filehash"
Remove-Item -path $outfile
Write-Host "Getting changelog info..."
$whatsnew = Invoke-WebRequest -Uri $whatsnewurl
$releasedate = [regex]::match($whatsnew.Content, "Released (.*)<br />").Groups[1].Value
$newfeatures = [regex]::match($whatsnew.Content, "New Features </span>(.*?)</p>", [Text.RegularExpressions.RegexOptions]::Singleline).Groups[1].Value
$newfeatures = $newfeatures -replace " •", "*"
$newfeatures = $newfeatures -replace "<br />", ""
$newfeatures = $newfeatures -replace "<br/>", ""
$enhancements = [regex]::match($whatsnew.Content, "Enhancements </span>(.*?)</p>", [Text.RegularExpressions.RegexOptions]::Singleline).Groups[1].Value
$enhancements = $enhancements -replace " •", "*"
$enhancements = $enhancements -replace "<br />", ""
$enhancements = $enhancements -replace "<br/>", ""
$bugfixes = [regex]::match($whatsnew.Content, "Bug Fixes </span>(.*?)</p>", [Text.RegularExpressions.RegexOptions]::Singleline).Groups[1].Value
$bugfixes = $bugfixes -replace " •", "*"
$bugfixes = $bugfixes -replace "<br />", ""
$bugfixes = $bugfixes -replace "<br/>", ""
Write-Host "Release date $releasedate"
Write-Host "Processing install file..."
$citemplate = Get-Content ".\templates\burnawarepremium\chocolateyInstall.ps1.template" -raw
$citemplate = $citemplate -replace "%hash%", "$filehash"
$citemplate = $citemplate -replace "%downloadurl%", "$url"
$citemplate | Out-File ".\burnawarepremium\tools\chocolateyInstall.ps1"
Write-Host "Processing nuspec file..."
$nstemplate = Get-Content ".\templates\burnawarepremium\burnawarepremium.nuspec.template" -raw
$nstemplate = $nstemplate -replace "%fileversion%", "$version"
$nstemplate = $nstemplate -replace "%releasedate%", "$releasedate"
$nstemplate = $nstemplate -replace "%newfeatures%", "$newfeatures"
$nstemplate = $nstemplate -replace "%enhancements%", "$enhancements"
$nstemplate = $nstemplate -replace "%bugfixes%", "$bugfixes"
$nstemplate | Out-File ".\burnawarepremium\burnawarepremium.nuspec"
Write-Host "Creating choco package..."
Set-Location -Path .\burnawarepremium
cpack
Write-Host "Uploading choco package..."
cpush
Write-Host "Delete folder..."
Set-Location -Path ..
Remove-Item -path .\burnawarepremium -recurse
Write-Host "Script completed"