-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
send_homebank.ps1
71 lines (57 loc) · 2.53 KB
/
send_homebank.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
# variables
$id = "homebank"
$name = "HomeBank"
$accounts = ""
$tags = "#homebank"
# extract latest version and release
Invoke-WebRequest -Uri "https://www.gethomebank.org/en/downloads.php" -OutFile "HOMEBANK.html"
Invoke-WebRequest -Uri "https://www.gethomebank.org/ChangeLog" -OutFile "release.txt"
$Source = Get-Content -path HOMEBANK.html -raw
$text = Get-Content -path release.txt
$Source -match 'The latest <b>([0-9]+(\.[0-9]+)+) stable</b>'
$tag = $matches[1]
$search = "[0-9]{4}-[0-9]{2}-[0-9]{2} Maxime Doyen"
$pattern = "$search(.*?)$search"
$result = [regex]::Match($text,$pattern).Groups[1].Value
$release = $result -replace ' :', ':'
$release = $release -replace ' :', ':'
$release = $release -replace ' *', "`n"
$release = $release -replace ' ', "`n"
$regex = '([0-9]{7,})'
$release = $release -replace $regex, '[${1}](https://bugs.launchpad.net/bugs/${1})'
$release = -join($release, "`n**Full changelog:** [https://www.gethomebank.org/ChangeLog](https://www.gethomebank.org/ChangeLog)");
# write new version and release
$file = "./$id/$id.nuspec"
$xml = New-Object XML
$xml.Load($file)
$xml.package.metadata.version = $tag
$xml.package.metadata.releaseNotes = $release
$xml.Save($file)
# download installer
Invoke-WebRequest -Uri "https://www.gethomebank.org/public/binaries/HomeBank-$tag-setup.exe" -OutFile "./$id/tools/$id.exe"
Remove-Item release.txt
# calculation of checksum
$TABLE = Get-FileHash "./$id/tools/$id.exe" -Algorithm SHA256
$SHA = $TABLE.Hash
# writing of VERIFICATION.txt
$content = "VERIFICATION
Verification is intended to assist the Chocolatey moderators and community
in verifying that this package's contents are trustworthy.
The installer have been downloaded from their official site repository listed on <https://www.gethomebank.org/en/downloads.php>
and can be verified like this:
1. Download the following installer:
Version $tag : <https://www.gethomebank.org/public/binaries/HomeBank-$tag-setup.exe>
2. You can use one of the following methods to obtain the checksum
- Use powershell function 'Get-Filehash'
- Use chocolatey utility 'checksum.exe'
checksum type: SHA256
checksum: $SHA
File 'LICENSE.txt' is obtained from the official website " | out-file -filepath "./$id/legal/VERIFICATION.txt"
# packaging
choco pack "./$id/$id.nuspec" --outputdirectory ".\$id"
If ($LastExitCode -eq 0) {
choco push "./$id/$id.$tag.nupkg" --source https://push.chocolatey.org/
./END.ps1
} else {
echo "Error in introduction - Exit code: $LastExitCode "
}