-
Notifications
You must be signed in to change notification settings - Fork 29
/
update.ps1
63 lines (53 loc) · 1.81 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
60
61
62
63
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $dropLocation,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $version,
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[string] $consolidatedBuildId
)
function updateFormula([string]$fileSuffix) {
$filePath = "./Formula/azure-functions-core-tools$fileSuffix.rb"
$content = Get-Content $filePath -Raw
# Update version
if ($content -match 'funcVersion = "(.*)"') {
$oldVersion = $Matches.1
$content = $content.Replace($oldVersion, $version)
} else {
throw "Failed to find funcVersion entry in ""$filePath"""
}
# Update consolidatedBuildId
if ($content -match 'consolidatedBuildId = "(.*)"') {
$oldConsolidatedBuildId = $Matches.1
$content = $content.Replace($oldConsolidatedBuildId, $consolidatedBuildId)
} else {
throw "Failed to find consolidatedBuildId entry in ""$filePath"""
}
# Update sha for each arch
foreach($arch in "osx-x64", "osx-arm64", "linux-x64") {
if ($content -match "funcArch = ""$arch""\s*funcSha = ""(.*)""") {
$oldSha = $Matches.1
$shaPath = Join-Path $dropLocation "Azure.Functions.Cli.$arch.$version.zip.sha2"
$sha = Get-Content -Path $shaPath
$content = $content.Replace($oldSha, $sha)
} else {
Write-Host "Skipping arch ""$arch"", not found in ""$filePath"""
}
}
Set-Content -Path $filePath -Value $content -NoNewline
Write-Host "Updated formula $filePath"
}
$majorVersion=([version]$version).Major
updateFormula "@$majorVersion"
# Also update files with legacy suffixes
if($majorVersion -eq "2")
{
updateFormula ""
}
elseif($majorVersion -eq "3")
{
updateFormula "-v3-preview"
}