forked from microsoft/security-devops-azdevops
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdate-BuildTaskVersions.ps1
More file actions
77 lines (65 loc) · 2.07 KB
/
Copy pathUpdate-BuildTaskVersions.ps1
File metadata and controls
77 lines (65 loc) · 2.07 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
68
69
70
71
72
73
74
75
76
77
# Copyright (c) Microsoft Corporation. All rights reserved.
Param
(
[Parameter(ParameterSetName="Major")]
[Switch] $Major,
[Parameter(ParameterSetName="Minor")]
[Switch] $Minor,
[Parameter(ParameterSetName="Patch")]
[Switch] $Patch,
[Parameter(ParameterSetName="Major")]
[Parameter(ParameterSetName="Minor")]
[Parameter(ParameterSetName="Patch")]
[Int] $Count = 1,
[Parameter(ParameterSetName="Major")]
[Parameter(ParameterSetName="Minor")]
[Parameter(ParameterSetName="Patch")]
[ValidateSet('src', 'lib')]
[String] $Directory = 'src',
[String] $Configuration = 'Debug'
)
if ($Count -eq 0)
{
Write-Host 'Count is 0. Skipping upticking task versions...'
return
}
$rootDirectory = Split-Path -Path $PSScriptRoot -Parent
$targetDirectory = Join-Path $rootDirectory $Directory
switch ($Directory)
{
'lib'
{
$targetDirectory = Join-Path $targetDirectory $Configuration
break
}
default
{
throw "Unknown folder to uptick build task versions for: $($Directory)"
}
}
if (-not (Test-Path -Path $targetDirectory -PathType 'Container'))
{
throw "Unable to find the build tasks folder to uptick: $($targetDirectory). If upticking the staging directory, ensure you have built the extension to uptick."
}
$updateBuildTaskVersion = Join-Path $PSScriptRoot 'Update-BuildTaskVersion.ps1'
Get-ChildItem -Path $targetDirectory -Include @('task.json', 'task.loc.json', 'task-external.json', 'task-external.loc.json') -Recurse | ForEach-Object {
$filePath = $_.FullName
switch ($PSCmdlet.ParameterSetName)
{
'Major'
{
& $updateBuildTaskVersion -FilePath $filePath -Major -Count $Count
break
}
'Minor'
{
& $updateBuildTaskVersion -FilePath $filePath -Minor -Count $Count
break
}
'Patch'
{
& $updateBuildTaskVersion -FilePath $filePath -Patch -Count $Count
break
}
}
}