Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Module Helpfiles, Pestertestfiles, and Changelog versioning tool #549

Merged
merged 4 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 47 additions & 16 deletions PowerShell/Deploy/Build-Module.ps1
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
[CmdletBinding()]
param (
[Parameter()]
[String]
$GitSourceBranch,
[Parameter()]
[String]
$GitSourceRepo,
[Parameter()]
# Validate Set for ReleaseType
[ValidateSet('Major', 'Minor', 'Patch')]
[Parameter(Mandatory = $true)]
[String]
kmaranionjc marked this conversation as resolved.
Show resolved Hide resolved
$ReleaseType,
[Parameter()]
[String]
$ModuleName,
[Parameter()]
[string]
$RequiredModulesRepo,
[Parameter()]
[Boolean]
$ManualModuleVersion
)
. "$PSScriptRoot/Get-Config.ps1" -GitSourceBranch:($GitSourceBranch) -GitSourceRepo:($GitSourceRepo) -ReleaseType:($ReleaseType) -RequiredModulesRepo:($RequiredModulesRepo)
. "$PSScriptRoot/Get-Config.ps1"
# Region Checking PowerShell Gallery module version
Write-Host ('[status]Check PowerShell Gallery for module version info')
$PSGalleryInfo = Get-PSGalleryModuleVersion -Name:($ModuleName) -ReleaseType:($RELEASETYPE) #('Major', 'Minor', 'Patch')
$PSGalleryInfo = Get-PSGalleryModuleVersion -Name:("JumpCloud") -ReleaseType:($RELEASETYPE) #('Major', 'Minor', 'Patch')
# Check to see if ManualModuleVersion parameter is set to true
if ($ManualModuleVersion) {
$ManualModuleVersionRetrieval = Get-Content -Path:($FilePath_psd1) | Where-Object { $_ -like '*ModuleVersion*' }
Expand All @@ -34,6 +24,38 @@ if ($ManualModuleVersion) {
}
Write-Host ('[status]PowerShell Gallery Name:' + $PSGalleryInfo.Name + ';CurrentVersion:' + $PSGalleryInfo.Version + '; NextVersion:' + $ModuleVersion )
# EndRegion Checking PowerShell Gallery module version

## Get the module version from the psd1 file and changelog
$VersionPsd1Regex = [regex]"(?<=ModuleVersion\s*=\s*')(([0-9]+)\.([0-9]+)\.([0-9]+))"
$VersionMatchPsd1 = Select-String -Path:($FilePath_psd1) -Pattern:($VersionPsd1Regex)
$PSD1Version = $VersionMatchPsd1.Matches.Value


$FilePath_ModuleChangelog = Join-Path -Path $PSScriptRoot -ChildPath '..\ModuleChangelog.md'
$ModuleChangelog = Get-Content -Path:($FilePath_ModuleChangelog)
$ModuleChangelogVersionRegex = "([0-9]+)\.([0-9]+)\.([0-9]+)"
$ModuleChangelogVersionMatch = ($ModuleChangelog | Select-Object -First 1) | Select-String -Pattern:($ModuleChangelogVersionRegex)
$ModuleChangelogVersion = $ModuleChangelogVersionMatch.Matches.Value

# Update ModuleChangelog.md File:
If ($ModuleChangelogVersion -ne $PSD1Version) {
# add a new version section to the module ModuleChangelog.md
Write-Host "[Status]: Appending new changelog for version: $PSD1Version"
$NewModuleChangelogRecord = New-ModuleChangelog -LatestVersion:($PSD1Version) -ReleaseNotes:('{{Fill in the Release Notes}}') -Features:('{{Fill in the Features}}') -Improvements:('{{Fill in the Improvements}}') -BugFixes('{{Fill in the Bug Fixes}}')

($NewModuleChangelogRecord + ($ModuleChangelog | Out-String)).Trim() | Set-Content -Path:($FilePath_ModuleChangelog) -Force
} else {
# Get content between latest version and last
$ModuleChangelogContent = Get-Content -Path:($FilePath_ModuleChangelog) | Select -First 3
$ReleaseDateRegex = [regex]'(?<=Release Date:\s)(.*)'
$ReleaseDateRegexMatch = $ModuleChangelogContent | Select-String -Pattern $ReleaseDateRegex
$ReleaseDate = $ReleaseDateRegexMatch.Matches.Value
$todaysDate = $(Get-Date -UFormat:('%B %d, %Y'))
if (($ReleaseDate) -and ($ReleaseDate -ne $todaysDate)) {
write-host "[Status] Updating Changelog date: $ReleaseDate to: $todaysDate)"
$ModuleChangelog.Replace($ReleaseDate, $todaysDate) | Set-Content $FilePath_ModuleChangelog
}
}
# Region Building New-JCModuleManifest
Write-Host ('[status]Building New-JCModuleManifest')
New-JCModuleManifest -Path:($FilePath_psd1) `
Expand All @@ -48,4 +70,13 @@ $NewModuleChangelogRecord = New-ModuleChangelog -LatestVersion:($ModuleVersion)
If (!(($ModuleChangelog | Select-Object -First 1) -match $ModuleVersion)) {
($NewModuleChangelogRecord + ($ModuleChangelog | Out-String)).Trim() | Set-Content -Path:($FilePath_ModuleChangelog) -Force
}
# EndRegion Updating module change log
# EndRegion Updating module change log

Write-Host "Building help files" -ForegroundColor Green
."$PSScriptRoot/Build-HelpFiles.ps1" -ModuleName "JumpCloud" -ModulePath (Get-Item -Path:($FilePath_psd1)).directory

Write-Host "Building Pester test files" -ForegroundColor Green
."$PSScriptRoot/Build-PesterTestFiles.ps1"

Write-Host "Building module" -ForegroundColor Green
."$PSScriptRoot/SdkSync/jcapiToSupportSync.ps1"
7 changes: 0 additions & 7 deletions PowerShell/Deploy/Build-PesterTestFiles.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
[CmdletBinding()]
param (
[Parameter()]
[string]
$RequiredModulesRepo
)

. "$PSScriptRoot/Get-Config.ps1"
################################################################################
# This script creates a new test file for each function in the PowerShell Module
Expand Down
6 changes: 0 additions & 6 deletions PowerShell/Deploy/SdkSync/jcapiToSupportSync.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
[CmdletBinding()]
param (
[Parameter()]
[string]
$RequiredModulesRepo
)
. "$PSScriptRoot/../Get-Config.ps1"
###########################################################################
$ApprovedFunctions = [Ordered]@{
Expand Down