-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.ps1
59 lines (47 loc) · 2.53 KB
/
update.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
Import-Module au
Import-Module PowerShellForGitHub
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition)
. $currentPath\helpers.ps1
$toolsPath = Join-Path -Path $currentPath -ChildPath 'tools'
$owner = 'xanderfrangos'
$repository = 'crushee'
function global:au_BeforeUpdate ($Package) {
Get-RemoteFiles -Purge -NoSuffix -Algorithm sha256
Copy-Item -Path "$toolsPath\VERIFICATION.txt.template" -Destination "$toolsPath\VERIFICATION.txt" -Force
Set-DescriptionFromReadme -Package $Package -ReadmePath '.\DESCRIPTION.md'
}
function global:au_AfterUpdate ($Package) {
$licenseUri = "https://github.com/raw/$($owner)/$($repository)/v$($Latest.SoftwareVersion)/LICENSE"
$licenseContents = Invoke-WebRequest -Uri $licenseUri -UseBasicParsing
Set-Content -Path 'tools\LICENSE.txt' -Value "From: $licenseUri`r`n`r`n$licenseContents" -NoNewline
}
function global:au_SearchReplace {
@{
"$($Latest.PackageName).nuspec" = @{
'(<packageSourceUrl>)[^<]*(</packageSourceUrl>)' = "`$1https://github.com/brogers5/chocolatey-package-$($Latest.PackageName)/tree/v$($Latest.Version)`$2"
'(<licenseUrl>)[^<]*(</licenseUrl>)' = "`$1https://github.com/$($owner)/$($repository)/blob/v$($Latest.SoftwareVersion)/LICENSE`$2"
'(<projectSourceUrl>)[^<]*(</projectSourceUrl>)' = "`$1https://github.com/$($owner)/$($repository)/tree/v$($Latest.SoftwareVersion)`$2"
'(<releaseNotes>)[^<]*(</releaseNotes>)' = "`$1https://github.com/$($owner)/$($repository)/releases/tag/v$($Latest.SoftwareVersion)`$2"
'(<copyright>)[^<]*(</copyright>)' = "`$1Copyright © $((Get-Date).Year) Xander Frangos`$2"
}
'tools\VERIFICATION.txt' = @{
'%checksumValue%' = "$($Latest.Checksum64)"
'%checksumType%' = "$($Latest.ChecksumType64.ToUpper())"
'%tagReleaseUrl%' = "https://github.com/$($owner)/$($repository)/releases/tag/v$($Latest.SoftwareVersion)"
'%binaryUrl%' = "$($Latest.Url64)"
'%binaryFileName%' = "$($Latest.FileName64)"
}
'tools\chocolateyinstall.ps1' = @{
"(^[$]archiveFileName\s*=\s*)('.*')" = "`$1'$($Latest.FileName64)'"
}
}
}
function global:au_GetLatest {
$version = Get-LatestStableVersion
return @{
Url64 = Get-SoftwareUri
Version = $version #This may change if building a package fix version
SoftwareVersion = $version
}
}
Update-Package -ChecksumFor None -NoReadme