/
update-version.ps1
64 lines (53 loc) · 1.84 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
52
53
54
55
56
57
58
59
60
61
62
63
64
function update-task() {
param(
[Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$true)]
[System.String]
$file,
[Parameter(Mandatory=$True, Position=1, ValueFromPipeline=$false)]
[System.String]
$major,
[Parameter(Mandatory=$True, Position=2, ValueFromPipeline=$false)]
[System.String]
$minor,
[Parameter(Mandatory=$True, Position=3, ValueFromPipeline=$false)]
[System.String]
$patch
)
$file = Resolve-Path $file
$jqMajor = '.version.Major="' + $major +'"';
$jqMinor = '.version.Minor="' + $minor +'"';
$jqPatch = '.version.Patch="' + $patch +'"';
Write-Host "Update task from $file to version $major.$minor.$patch"
Get-Content $file | jq $jqMajor | jq $jqMinor | jq $jqPatch | Set-Content $file -NoNewline
}
function update-manifest() {
param(
[Parameter(Mandatory=$True, Position=0, ValueFromPipeline=$true)]
[System.String]
$file,
[Parameter(Mandatory=$True, Position=1, ValueFromPipeline=$false)]
[System.String]
$version
)
$file = Resolve-Path $file
$jqVersion = '.version="' + $version +'"';
Write-Host "Update manifest $file version to $version"
Get-Content $file | jq $jqVersion | Set-Content $file -NoNewline
}
function update-md-files()
{
param(
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $true)]
[System.String]
$file,
[Parameter(Mandatory = $True, Position = 1, ValueFromPipeline = $false)]
[System.String]
$oldVersion,
[Parameter(Mandatory = $True, Position = 2, ValueFromPipeline = $false)]
[System.String]
$newVersion
)
$file = Resolve-Path $file
Write-Host "Update md file $file version from $oldVersion to $newVersion"
((Get-Content $file -Raw) -replace $oldVersion, $newVersion) | Set-Content $file -NoNewline
}