-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetNovaModuleVersion.ps1
More file actions
44 lines (39 loc) · 1.78 KB
/
Copy pathSetNovaModuleVersion.ps1
File metadata and controls
44 lines (39 loc) · 1.78 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
function Get-NovaModuleVersionWriteResult {
[CmdletBinding()]
param(
[Parameter(Mandatory)][string]$ProjectFile,
[Parameter(Mandatory)][string]$PreviousVersion,
[Parameter(Mandatory)][string]$NewVersion,
[switch]$Applied
)
return [pscustomobject]@{
ProjectFile = $ProjectFile
Target = [System.IO.Path]::GetFileName($ProjectFile)
PreviousVersion = $PreviousVersion
NewVersion = $NewVersion
Applied = [bool]$Applied
}
}
function Set-NovaModuleVersion {
[CmdletBinding(SupportsShouldProcess = $true)]
param(
[ValidateSet('Major', 'Minor', 'Patch')]
[string]$Label = 'Patch',
[switch]$PreviewRelease,
[switch]$StableRelease,
[pscustomobject]$ProjectInfo
)
Write-Verbose 'Running Version Update'
$versionUpdatePlan = Get-NovaVersionUpdatePlan -ProjectInfo $ProjectInfo -Label $Label -PreviewRelease:$PreviewRelease -StableRelease:$StableRelease
$jsonContent = Read-ProjectJsonData -ProjectJsonPath $versionUpdatePlan.ProjectFile
$previousVersion = [string]$jsonContent.Version
$newVersion = $versionUpdatePlan.NewVersion.ToString()
$target = [System.IO.Path]::GetFileName($versionUpdatePlan.ProjectFile)
$action = "Set module version to $newVersion"
if (-not $PSCmdlet.ShouldProcess($target, $action)) {
return Get-NovaModuleVersionWriteResult -ProjectFile $versionUpdatePlan.ProjectFile -PreviousVersion $previousVersion -NewVersion $newVersion
}
$jsonContent.Version = $newVersion
Write-ProjectJsonData -ProjectJsonPath $versionUpdatePlan.ProjectFile -Data $jsonContent
return Get-NovaModuleVersionWriteResult -ProjectFile $versionUpdatePlan.ProjectFile -PreviousVersion $previousVersion -NewVersion $newVersion -Applied
}