Skip to content

Commit 07e31b1

Browse files
committed
Updated build
1 parent eec95e5 commit 07e31b1

File tree

4 files changed

+349
-317
lines changed

4 files changed

+349
-317
lines changed

build/Build-PSModule.ps1

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ param
22
(
33
# Directory used to base all relative paths
44
[Parameter(Mandatory = $false)]
5-
[string] $BaseDirectory = "..\",
5+
[string] $BaseDirectory = ".\",
66
#
77
[Parameter(Mandatory = $false)]
88
[string] $OutputDirectory = ".\build\release\",
@@ -23,12 +23,18 @@ param
2323
[string] $LicensePath = ".\LICENSE",
2424
#
2525
[Parameter(Mandatory = $false)]
26-
[switch] $SkipMergingNestedModuleScripts
26+
[switch] $SkipMergingNestedModuleScripts,
27+
# If true, builds the module for production, otherwise builds a preview module that is installed with -AllowPrerelease
28+
[Parameter()]
29+
[switch]$ProductionBuild
2730
)
2831

2932
## Initialize
3033
Import-Module "$PSScriptRoot\CommonFunctions.psm1" -Force -WarningAction SilentlyContinue -ErrorAction Stop
3134

35+
## Increment the build number
36+
&$PSScriptRoot\Set-Version.ps1 -preview:(!$ProductionBuild)
37+
3238
[System.IO.DirectoryInfo] $BaseDirectoryInfo = Get-PathInfo $BaseDirectory -InputPathType Directory -ErrorAction Stop
3339
[System.IO.DirectoryInfo] $OutputDirectoryInfo = Get-PathInfo $OutputDirectory -InputPathType Directory -DefaultDirectory $BaseDirectoryInfo.FullName -ErrorAction SilentlyContinue
3440
[System.IO.DirectoryInfo] $SourceDirectoryInfo = Get-PathInfo $SourceDirectory -InputPathType Directory -DefaultDirectory $BaseDirectoryInfo.FullName -ErrorAction Stop
@@ -86,4 +92,4 @@ if (!$SkipMergingNestedModuleScripts) {
8692
}
8793

8894
## Sign Module
89-
&$PSScriptRoot\Sign-PSModule.ps1 -ModuleManifestPath $OutputModuleManifestFileInfo.FullName | Format-Table Path, Status, StatusMessage
95+
#&$PSScriptRoot\Sign-PSModule.ps1 -ModuleManifestPath $OutputModuleManifestFileInfo.FullName | Format-Table Path, Status, StatusMessage

build/Publish-PSModule.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ param
33
(
44
# Path to Module Manifest
55
[Parameter(Mandatory = $false)]
6-
[string] $ModuleManifestPath = ".\release\*\*.*.*\*.psd1",
6+
[string] $ModuleManifestPath = ".\build\release\*\*.*.*\*.psd1",
77
# Repository for PowerShell Gallery
88
[Parameter(Mandatory = $false)]
99
[string] $RepositorySourceLocation = 'https://www.powershellgallery.com/api/v2',

build/Set-Version.ps1

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
[CmdletBinding()]
2+
Param(
3+
[Parameter()]
4+
[switch]$preview = $false
5+
)
6+
7+
## Initialize
8+
Import-Module "$PSScriptRoot\CommonFunctions.psm1" -Force -WarningAction SilentlyContinue -ErrorAction Stop
9+
10+
$ModuleRoot = "./src/"
11+
$ModuleManifestPath = "./src/*.psd1"
12+
13+
14+
$ManifestPath = Get-PathInfo $ModuleManifestPath -DefaultFilename "*.psd1" -ErrorAction Stop | Select-Object -Last 1
15+
$moduleName = Split-Path $ManifestPath -LeafBase
16+
17+
if ( -not (Test-Path $ManifestPath )) {
18+
Write-Error "Could not find PowerShell module manifest ($ManifestPath)"
19+
throw
20+
} else {
21+
# Get the current version of the module from the PowerShell gallery
22+
$previousVersion = (Find-Module -Name $moduleName -AllowPrerelease:$preview).Version
23+
Write-Host "Previous version: $previousVersion"
24+
25+
$ver = [version]($previousVersion -replace '-preview')
26+
27+
# Set new version number. If it is pre-release, increment the build number otherwise increment the minor version.
28+
$major = $ver.Major # Update this to change the major version number.
29+
$minor = $ver.Minor
30+
31+
if ($preview) {
32+
$build = $ver.Build + 1
33+
} else {
34+
$minor = $ver.Minor + 1
35+
$build = 0 # Reset the build number when incrementing the minor version.
36+
}
37+
38+
$NewVersion = '{0}.{1}.{2}' -f $major, $minor, $build
39+
40+
# $publicScripts = @( Get-ChildItem -Path "$ModuleRoot/public" -Recurse -Filter "*.ps1" )
41+
# $FunctionNames = @( $publicScripts.BaseName | Sort-Object )
42+
43+
$previewLabel = if ($preview) { '-preview' } else { '' }
44+
45+
# Update-ModuleManifest -Path $ManifestPath -ModuleVersion $NewVersion -FunctionsToExport $FunctionNames -Prerelease $previewLabel
46+
47+
Update-ModuleManifest -Path $ManifestPath -ModuleVersion $NewVersion -Prerelease $previewLabel
48+
}
49+
50+
$NewVersion += $previewLabel
51+
Write-Host "New version: $NewVersion"
52+
#Add-Content -Path $env:GITHUB_OUTPUT -Value "newtag=$NewVersion"
53+
#Add-Content -Path $env:GITHUB_OUTPUT -Value "tag=$NewVersion"

0 commit comments

Comments
 (0)