-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate.ps1
More file actions
67 lines (55 loc) · 3 KB
/
update.ps1
File metadata and controls
67 lines (55 loc) · 3 KB
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
[CmdletBinding()]
param($IncludeStream)
Import-Module au
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition)
. $currentPath\helpers.ps1
$toolsPath = Join-Path -Path $currentPath -ChildPath 'tools'
$gitLabSoftwareRepo = 'CalcProgrammer1/OpenRGB'
$codebergSoftwareRepo = 'OpenRGB/OpenRGB'
function global:au_GetLatest {
$streams = [ordered] @{
ReleaseCandidateWinRing0 = Get-LatestReleaseCandidateVersionInfo -WinRing0
ReleaseCandidate = Get-LatestReleaseCandidateVersionInfo
Stable = Get-LatestStableVersionInfo
}
return @{ Streams = $streams }
}
function global:au_BeforeUpdate ($Package) {
Get-RemoteFiles -Purge -NoSuffix -Algorithm sha256
$templateFilePath = Join-Path -Path $toolsPath -ChildPath 'VERIFICATION.txt.template'
$verificationFilePath = Join-Path -Path $toolsPath -ChildPath 'VERIFICATION.txt'
Copy-Item -Path $templateFilePath -Destination $verificationFilePath -Force
Set-DescriptionFromReadme -Package $Package -ReadmePath '.\DESCRIPTION.md'
}
function global:au_AfterUpdate ($Package) {
$licenseUri = "https://gitlab.com/$($gitLabSoftwareRepo)/-/raw/$($Latest.Tag)/LICENSE"
$licenseContents = Invoke-WebRequest -Uri $licenseUri -UseBasicParsing
$licensePath = Join-Path -Path $toolsPath -ChildPath 'LICENSE.txt'
Set-Content -Path $licensePath -Value "From: $licenseUri`r`n`r`n$licenseContents"
#Archive the current source code to prepare for possible redistribution requests, as required by GPLv2
Get-SourceCode -TagName $Latest.Tag
}
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://gitlab.com/$($gitLabSoftwareRepo)/-/blob/$($Latest.Tag)/LICENSE`$2"
'(<projectSourceUrl>)[^<]*(</projectSourceUrl>)' = "`$1https://gitlab.com/$($gitLabSoftwareRepo)/-/tree/$($Latest.Tag)`$2"
'(<releaseNotes>)[^<]*(</releaseNotes>)' = "`$1https://codeberg.org/$($codebergSoftwareRepo)/releases/tag/$($Latest.Tag)`$2"
'(<copyright>)[^<]*(</copyright>)' = "`$1Copyright (C) $(Get-Date -Format yyyy) Adam Honse`$2"
}
'tools\VERIFICATION.txt' = @{
'%url32%' = "$($Latest.Url32)"
'%url64%' = "$($Latest.Url64)"
'%checksumType%' = "$($Latest.ChecksumType32.ToUpper())"
'%file32%' = "$($Latest.FileName32)"
'%checksum32%' = "$($Latest.Checksum32)"
'%file64%' = "$($Latest.FileName64)"
'%checksum64%' = "$($Latest.Checksum64)"
}
'tools\chocolateyinstall.ps1' = @{
'(^[$]archiveFileNames\s*=\s*)(.*)' = "`$1@('$($Latest.FileName64)', '$($Latest.FileName32)')"
}
}
}
Update-Package -ChecksumFor None -IncludeStream $IncludeStream -NoReadme