Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e25f1e1
added support for preliminary builds
mdaneri Mar 4, 2025
2247d58
Update pode.build.ps1
mdaneri Mar 4, 2025
c2da4fd
Update pode.build.ps1
mdaneri Mar 5, 2025
eedaec6
Add sort locales and build prerelease
mdaneri Mar 7, 2025
5e729b2
Update pode.build.ps1
mdaneri Mar 7, 2025
90b50a8
sort Locales
mdaneri Mar 7, 2025
edf71e0
Update prerelease.build.ps1
mdaneri Mar 7, 2025
2e1ae43
Update prerelease.build.ps1
mdaneri Mar 7, 2025
58dfb1a
Update prerelease.build.ps1
mdaneri Mar 7, 2025
a8f9976
Update prerelease.build.ps1
mdaneri Mar 7, 2025
91340e6
Update pode.build.ps1
mdaneri Mar 7, 2025
81f49c9
Update prerelease.build.ps1
mdaneri Mar 7, 2025
a276cfa
Update prerelease.build.ps1
mdaneri Mar 7, 2025
fc37437
Update pode.build.ps1
mdaneri Mar 7, 2025
cf10ba9
update Sort-Language
mdaneri Mar 8, 2025
d8ea1ac
Fix '' replacement
mdaneri Mar 8, 2025
9388c54
Update prerelease.build.ps1
mdaneri Mar 8, 2025
f554923
Fix not english languages
mdaneri Mar 8, 2025
59b2c06
update Group-LanguageResource
mdaneri Mar 8, 2025
cc903c2
implement language automerge
mdaneri Mar 9, 2025
2408577
Update prerelease.build.ps1
mdaneri Mar 10, 2025
c87704a
Update prerelease.build.ps1
mdaneri Mar 10, 2025
1d683ae
Update prerelease.build.ps1
mdaneri Mar 10, 2025
89b162a
Update prerelease.build.ps1
mdaneri Mar 10, 2025
de45c62
Update prerelease.build.ps1
mdaneri Mar 10, 2025
b14215b
fix issue with version inside a runspace
mdaneri Mar 13, 2025
92952ff
Merge remote-tracking branch 'upstream/develop' into prerelease-support
mdaneri Mar 18, 2025
2d851ea
Merge remote-tracking branch 'upstream/develop' into prerelease-support
mdaneri Mar 29, 2025
bbbc7e6
Merge remote-tracking branch 'upstream/develop' into prerelease-support
mdaneri Apr 12, 2025
0e0c30e
Merge branch 'develop' into prerelease-support
mdaneri Apr 12, 2025
01df96a
Merge remote-tracking branch 'upstream/develop' into prerelease-support
mdaneri Apr 19, 2025
ba69e95
Merge remote-tracking branch 'upstream/develop' into prerelease-support
mdaneri Apr 21, 2025
270ecf3
Merge branch 'develop' into prerelease-support
mdaneri Apr 25, 2025
f06a5ba
Merge branch 'develop' into prerelease-support
mdaneri Apr 27, 2025
93cfd39
revert locales
mdaneri May 15, 2025
ef98e63
Update Helpers.ps1
mdaneri May 15, 2025
837545c
Update Utilities.ps1
mdaneri May 15, 2025
fa73616
Update Context.ps1
mdaneri May 15, 2025
fb14280
fixes
mdaneri May 15, 2025
906c864
Update pode.build.ps1
mdaneri May 15, 2025
e1a8ae9
Delete prerelease.build.ps1
mdaneri May 18, 2025
d8e1a2b
Update Utilities.ps1
mdaneri May 18, 2025
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
95 changes: 89 additions & 6 deletions pode.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@
.PARAMETER Version
Specifies the project version for stamping, packaging, and documentation. Defaults to '0.0.0'.

.PARAMETER Prerelease
Specifies the prerelease label to append to the module version, following semantic versioning conventions.
Examples include 'alpha.1', 'alpha.2', 'beta.1', etc. This label indicates the stability and iteration of the prerelease version.

.PARAMETER PersistVersion
If specified, the provided version and prerelease label will be saved to `Version.json`.
This ensures future builds use the same versioning information unless explicitly overridden.

.PARAMETER PesterVerbosity
Sets the verbosity level for Pester tests. Options: None, Normal, Detailed, Diagnostic.

Expand Down Expand Up @@ -76,6 +84,9 @@
Invoke-Build -Task Docs
# Builds and serves the documentation locally.

Invoke-Build -Task Build -Version '2.13.0' -Prerelease 'beta.1' -PersistVersion
# Saves "2.13.0-beta.1" to Version.json for future builds.

.LINK
For more information, visit https://github.com/Badgerati/Pode
#>
Expand All @@ -89,7 +100,13 @@
[Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingPositionalParameters', '')]
param(
[string]
$Version = '0.0.0',
$Version,

[string]
$Prerelease,

[switch]
$PersistVersion,

[string]
[ValidateSet('None', 'Normal' , 'Detailed', 'Diagnostic')]
Expand Down Expand Up @@ -488,18 +505,27 @@ function Invoke-PodeBuildDotnetBuild {

# Optionally set assembly version
if ($Version) {
Write-Output "Assembly Version: $Version"
$AssemblyVersion = "-p:Version=$Version"
if ($Prerelease) {
Write-Output "Assembly Version: $Version-$Prerelease"
$AssemblyVersion = "-p:VersionPrefix=$Version"
$AssemblyPrerelease = "-p:VersionSuffix=$Prerelease"
}
else {
Write-Output "Assembly Version: $Version"
$AssemblyVersion = "-p:Version=$Version"
$AssemblyPrerelease = ''
}
}
else {
$AssemblyVersion = ''
$AssemblyPrerelease = ''
}

# restore dependencies
dotnet restore

# Use dotnet publish for .NET Core and .NET 5+
dotnet publish --configuration Release --self-contained --framework $target $AssemblyVersion --output ../Libs/$target
dotnet publish --configuration Release --self-contained --framework $target $AssemblyVersion $AssemblyPrerelease --output ../Libs/$target

if (!$?) {
throw "Build failed for target framework '$target'."
Expand Down Expand Up @@ -889,6 +915,56 @@ if (($null -eq $PSCmdlet.MyInvocation) -or ($PSCmdlet.MyInvocation.BoundParamete
return
}

# Import Version File if needed
if ([string]::IsNullOrEmpty($Version)) {
if (Test-Path './Version.json' -PathType Leaf) {
$importedVersion = Get-Content -Path './Version.json' | ConvertFrom-Json
if ($importedVersion.Version) {
$Version = $importedVersion.Version
}
if ($importedVersion.Prerelease) {
$Prerelease = $importedVersion.Prerelease
}
}
else {
$Version = '0.0.0'
if ($PersistVersion) {
Write-Error 'The -PersistVersion parameter requires the -Version parameter to be specified.'
return
}
}
}
elseif ($PersistVersion) {
if ($Prerelease) {
[ordered]@{Version = $Version; Prerelease = $Prerelease } | ConvertTo-Json | Out-File './Version.json'
}
else {
[ordered]@{Version = $Version } | ConvertTo-Json | Out-File './Version.json'
}
}


Write-Host '---------------------------------------------------' -ForegroundColor DarkCyan

# Display the Pode build version
if ($Prerelease) {
Write-Host "Pode Build: v$Version-$Prerelease (Pre-release)" -ForegroundColor DarkCyan
}
else {
if ($Version -eq '0.0.0') {
Write-Host 'Pode Build: [Development Version]' -ForegroundColor DarkCyan
}
else {
Write-Host "Pode Build: v$Version" -ForegroundColor DarkCyan
}
}

# Display the current UTC time in a readable format
$utcTime = (Get-Date).ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss 'UTC'")
Write-Host "Start Time: $utcTime" -ForegroundColor DarkCyan

Write-Host '---------------------------------------------------' -ForegroundColor DarkCyan


Add-BuildTask Default {
Write-Host 'Tasks in the Build Script:' -ForegroundColor DarkMagenta
Expand Down Expand Up @@ -939,7 +1015,13 @@ Add-BuildTask Default {
# Synopsis: Stamps the version onto the Module
Add-BuildTask StampVersion {
$pwshVersions = Get-PodeBuildPwshEOL
(Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionsUntested\$', $pwshVersions.eol -replace '\$versionsSupported\$', $pwshVersions.supported -replace '\$buildyear\$', ((get-date).Year) } | Set-Content ./pkg/Pode.psd1
$prereleaseValue = if ($Prerelease) {
"Prerelease = '$Prerelease'"
}
else {
''
}
(Get-Content ./pkg/Pode.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version -replace '\$versionsUntested\$', $pwshVersions.eol -replace '\$versionsSupported\$', $pwshVersions.supported -replace '\$buildyear\$', ((get-date).Year) -replace '#\$Prerelease-Here\$', $prereleaseValue } | Set-Content ./pkg/Pode.psd1
(Get-Content ./pkg/Pode.Internal.psd1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./pkg/Pode.Internal.psd1
(Get-Content ./packers/choco/pode_template.nuspec) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/pode.nuspec
(Get-Content ./packers/choco/tools/ChocolateyInstall_template.ps1) | ForEach-Object { $_ -replace '\$version\$', $Version } | Set-Content ./packers/choco/tools/ChocolateyInstall.ps1
Expand Down Expand Up @@ -1682,7 +1764,7 @@ Add-BuildTask SetupPowerShell {
#>

# Synopsis: Build the Release Notes
task ReleaseNotes {
Add-BuildTask ReleaseNotes {
if ([string]::IsNullOrWhiteSpace($ReleaseNoteVersion)) {
Write-Host 'Please provide a ReleaseNoteVersion' -ForegroundColor Red
return
Expand Down Expand Up @@ -1818,3 +1900,4 @@ task ReleaseNotes {
Write-Host ''
}
}

3 changes: 3 additions & 0 deletions src/Pode.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,9 @@
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{

#$Prerelease-Here$

# Tags applied to this module. These help with module discovery in online galleries.
Tags = @(
'powershell', 'web', 'server', 'http', 'https', 'listener', 'rest', 'api', 'tcp',
Expand Down
44 changes: 29 additions & 15 deletions src/Pode.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ if ([string]::IsNullOrEmpty($UICulture)) {
$UICulture = $PsUICulture
}


function Test-PodeAssembly {
$podeDll = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq 'Pode' }

if ($podeDll) {
if ( $PodeManifest.ModuleVersion -ne '$version$') {
$moduleVersion = ([version]::new($PodeManifest.ModuleVersion + '.0'))
if ($podeDll.GetName().Version -ne $moduleVersion) {
# An existing incompatible Pode.DLL version {0} is loaded. Version {1} is required. Open a new Powershell/pwsh session and retry.
throw ($PodeLocale.incompatiblePodeDllExceptionMessage -f $podeDll.GetName().Version, $moduleVersion)
}
$assemblyInformationalVersion = $podeDll.CustomAttributes.Where({ $_.AttributeType -eq [System.Reflection.AssemblyInformationalVersionAttribute] })
if ($null -ne $PodeManifest.PrivateData.PSData.Prerelease) {
if (! $assemblyInformationalVersion.ConstructorArguments.Value.Contains($PodeManifest.PrivateData.PSData.Prerelease)) {
throw ($PodeLocale.incompatiblePodeDllExceptionMessage -f $assemblyInformationalVersion.ConstructorArguments.Value, "$moduleVersion-$($PodeManifest.PrivateData.PSData.Prerelease)")
}
}
elseif ($assemblyInformationalVersion.ConstructorArguments.Value.Contains('-')) {
throw ($PodeLocale.incompatiblePodeDllExceptionMessage -f $assemblyInformationalVersion.ConstructorArguments.Value, $moduleVersion)
}
}
return $true
}
return $false
}

try {
try {
#The list of all available supported culture is available here https://azuliadesigns.com/c-sharp-tutorials/list-net-culture-country-codes/
Expand All @@ -75,21 +101,9 @@ try {
$moduleManifestPath = Join-Path -Path $root -ChildPath 'Pode.psd1'

# Import the module manifest to access its properties
$moduleManifest = Import-PowerShellDataFile -Path $moduleManifestPath -ErrorAction Stop


$podeDll = [AppDomain]::CurrentDomain.GetAssemblies() | Where-Object { $_.GetName().Name -eq 'Pode' }
$PodeManifest = Import-PowerShellDataFile -Path $moduleManifestPath -ErrorAction Stop

if ($podeDll) {
if ( $moduleManifest.ModuleVersion -ne '$version$') {
$moduleVersion = ([version]::new($moduleManifest.ModuleVersion + '.0'))
if ($podeDll.GetName().Version -ne $moduleVersion) {
# An existing incompatible Pode.DLL version {0} is loaded. Version {1} is required. Open a new Powershell/pwsh session and retry.
throw ($PodeLocale.incompatiblePodeDllExceptionMessage -f $podeDll.GetName().Version, $moduleVersion)
}
}
}
else {
if (! (Test-PodeAssembly)) {
# fetch the .net version and the libs path
$version = [System.Environment]::Version.Major
$libsPath = "$($root)/Libs"
Expand All @@ -109,6 +123,7 @@ try {

# append Pode.dll and mount
Add-Type -LiteralPath "$($netFolder)/Pode.dll" -ErrorAction Stop
$null = Test-PodeAssembly
}

# load private functions
Expand Down Expand Up @@ -143,4 +158,3 @@ finally {
# Cleanup temporary variables
Remove-Variable -Name 'tmpPodeLocale', 'localesPath', 'moduleManifest', 'root', 'version', 'libsPath', 'netFolder', 'podeDll', 'sysfuncs', 'sysaliases', 'funcs', 'aliases', 'moduleManifestPath', 'moduleVersion' -ErrorAction SilentlyContinue
}

19 changes: 16 additions & 3 deletions src/Public/Utilities.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1361,8 +1361,8 @@ Gets the version of the Pode module.
.DESCRIPTION
The Get-PodeVersion function checks the version of the Pode module specified in the module manifest. If the module version is not a placeholder value ('$version$'), it returns the actual version prefixed with 'v.'. If the module version is the placeholder value, indicating the development branch, it returns '[develop branch]'.

.PARAMETER None
This function does not accept any parameters.
.PARAMETER Raw
If this switch is set, the function will return the raw version number as a [version] object instead of a string.

.OUTPUTS
System.String
Expand All @@ -1385,9 +1385,22 @@ This function assumes that $moduleManifest is a hashtable representing the loade

#>
function Get-PodeVersion {
param(
[switch]
$Raw
)
$moduleManifest = Get-PodeModuleManifest
if ($moduleManifest.ModuleVersion -ne '$version$') {
return "v$($moduleManifest.ModuleVersion)"
$version = if ( $Raw) {
$moduleManifest.ModuleVersion
}
else {
"v$($moduleManifest.ModuleVersion)"
}
if ($moduleManifest.PrivateData.PSData.Prerelease) {
return "$version-$($moduleManifest.PrivateData.PSData.Prerelease)"
}
return $version
}
else {
return '[dev]'
Expand Down