-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate-version.ps1
51 lines (41 loc) · 1.51 KB
/
update-version.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
Param (
[parameter(Mandatory=$true, Position=0, HelpMessage = "The new version string")]
$version
)
# Patches a file using the specified regular expression search string and replacement
function Patch-File {
Param (
$Path,
$Search,
$Replace
)
Write-Host "Updating $Path" -ForegroundColor Cyan
$content = Get-Content -Path $Path -Raw
$content = $content -replace $Search, $Replace
Set-Content -Path $Path -NoNewline -Value $content
}
# Patches image tags in a YAML file
function Patch-ImageTags {
Param ($Path)
Patch-File -Path $Path `
-Search '"index.docker.io/tensorworks/(.+):(.+)"' `
-Replace "`"index.docker.io/tensorworks/`$1:$version`""
}
# Update the version strings in all of our files, ready for a new release
Write-Host "Updating version strings to $version..." -ForegroundColor Green
# Update the version string for the device discovery library
Patch-File -Path "$PSScriptRoot\library\src\DeviceDiscovery.cpp" `
-Search '#define LIBRARY_VERSION L"(.+)"' `
-Replace "#define LIBRARY_VERSION L`"$version`""
# Update the version string for the device plugins
Patch-File -Path "$PSScriptRoot\plugins\internal\plugin\common_main.go" `
-Search 'const version = "(.+)"' `
-Replace "const version = `"$version`""
# Update the deployment YAML files
foreach ($file in Get-ChildItem -Path "$PSScriptRoot\deployments\*.yml") {
Patch-ImageTags -Path $file.FullName
}
# Update the example YAML files
foreach ($file in Get-ChildItem -Path "$PSScriptRoot\examples\*\*.yml") {
Patch-ImageTags -Path $file.FullName
}