-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathrelease.ps1
More file actions
68 lines (64 loc) · 3.88 KB
/
release.ps1
File metadata and controls
68 lines (64 loc) · 3.88 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
$myMod = 'verkadaModule'
$mypath = $PSScriptRoot | Split-Path -Parent
import-Module $mypath/$myMod/$myMod.psm1
update-ModuleManifest -Path "$mypath/$myMod/$myMod.psd1" -FunctionsToExport (Get-ChildItem -Path $mypath/$myMod/Public/ -Recurse -Include *.ps1 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty BaseName) -AliasesToExport (Get-Command -Module verkadaModule | ForEach-Object {Get-Alias -Definition $_.name -ea 0} | Select-Object -ExpandProperty Name)
import-Module $mypath/$myMod/$myMod.psm1 -Force
update-ModuleManifest -Path "$mypath/$myMod/$myMod.psd1" -FunctionsToExport (Get-ChildItem -Path $mypath/$myMod/Public/ -Recurse -Include *.ps1 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty BaseName) -AliasesToExport (Get-Command -Module verkadaModule | ForEach-Object {Get-Alias -Definition $_.name -ea 0} | Select-Object -ExpandProperty Name)
Get-ChildItem -Path $mypath/docs/function-documentation -Recurse | Remove-Item -Force -Recurse -Confirm:$false | Out-Null
New-MarkdownHelp -Module $myMod -OutputFolder $mypath/docs/function-documentation -Force | Out-Null
Write-output "# Verkada PowerShell module`n" | Out-File $mypath/docs/reference.md -Force
Write-output "## Command Documentation" | Out-File $mypath/docs/reference.md -Append
Get-ChildItem $mypath/$myMod/Public/ | ForEach-Object {
If(!($_.BaseName -eq 'Legacy')){
Write-Output "`n### $($_.BaseName)`n" | Out-File $mypath/docs/reference.md -Append
$tempDir=$_.BaseName
Get-ChildItem $_ | ForEach-Object {
if (!(Test-Path -Path "$mypath/docs/function-documentation/$tempDir/" -PathType Container)) {
New-Item -Path "$mypath/docs/function-documentation/$tempDir/" -ItemType Directory -Force
}
Move-Item -Path "$mypath/docs/function-documentation/$($_.BaseName).md" -Destination "$mypath/docs/function-documentation/$tempDir/" -Force
Write-Output "* [$($_.BaseName)](function-documentation/$tempDir/$($_.BaseName).md)" | Out-File $mypath/docs/reference.md -Append
}
} else {
Write-Output `n"### Legacy" | Out-File $mypath/docs/reference.md -Append
$tempDir=$_.BaseName
Get-ChildItem $_ | ForEach-Object {
Write-Output "`n#### Legacy $($_.BaseName)`n" | Out-File $mypath/docs/reference.md -Append
$tempDir2=$_.BaseName
Get-ChildItem $_ | ForEach-Object {
if (!(Test-Path -Path "$mypath/docs/function-documentation/$tempDir/$tempDir2/" -PathType Container)) {
New-Item -Path "$mypath/docs/function-documentation/$tempDir/$tempDir2/" -ItemType Directory -Force
}
Move-Item -Path "$mypath/docs/function-documentation/$($_.BaseName).md" -Destination "$mypath/docs/function-documentation/$tempDir/$tempDir2/" -Force
Write-Output "* [$($_.BaseName)](function-documentation/$tempDir/$tempDir2/$($_.BaseName).md)" | Out-File $mypath/docs/reference.md -Append
}
}
}
}
Get-ChildItem $mypath/$myMod/Private/ | ForEach-Object {
Get-ChildItem $_ | ForEach-Object {
if (!(Test-Path -Path "$mypath/docs/function-documentation/private/" -PathType Container)) {
New-Item -Path "$mypath/docs/function-documentation/private/" -ItemType Directory -Force
}
Move-Item -Path "$mypath/docs/function-documentation/$($_.BaseName).md" -Destination "$mypath/docs/function-documentation/private/" -Force
}
}
$manifest = Import-PowerShellDataFile "$mypath/$myMod/$myMod.psd1"
[version]$version = $Manifest.ModuleVersion
switch ($Args[0]) {
'major' {
# Add one to the major of the version number
[version]$NewVersion = "{0}.{1}.{2}" -f ($Version.Major + 1), '0', '0'
}
'minor' {
# Add one to the minor of the version number
[version]$NewVersion = "{0}.{1}.{2}" -f $Version.Major, ($Version.Minor + 1), '0'
}
default {
# Add one to the build of the version number
[version]$NewVersion = "{0}.{1}.{2}" -f $Version.Major, $Version.Minor, ($Version.Build + 1)
}
}
# Update the manifest file
Update-ModuleManifest -Path "$mypath/$myMod/$myMod.psd1" -ModuleVersion $NewVersion
return $NewVersion.ToString()