Skip to content

Commit 6297910

Browse files
authored
Merge pull request #143 from stiwicourage/develop
Update Node.js version requirements for release automation
2 parents f9485c2 + e7b506d commit 6297910

12 files changed

Lines changed: 154 additions & 4 deletions

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
101101
- CI bump now reuses the already activated built-module command when the current session is already running from
102102
`dist/`, so publish-then-bump prerelease automation can continue in the same session without losing private helper
103103
bindings.
104+
- `Update-NovaModuleVersion -ContinuousIntegration` now also falls back to a patch bump when `HEAD` already matches
105+
the latest tag, so release automation can prepare the next prerelease version without requiring an extra commit.
104106
- Keep standalone `nova bump` output stable by formatting version-update results in the CLI layer instead of relying on
105107
PowerShell's default object rendering.
106108
- `nova bump --what-if` and `% run.ps1` now surface a predictable summary for previous version, new version, label,
@@ -116,6 +118,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
116118
failing during parameter binding.
117119
- Fix configuration and validation errors so empty `project.json` files and unsupported `Manifest` keys fail fast with
118120
clear messages.
121+
- Fix semantic-release PSGallery publishing on fresh CI runners by bootstrapping the PSResourceGet repository store
122+
before
123+
`Publish-PSResource` runs.
119124

120125
### Changed
121126

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,9 @@ These switches keep the behavior explicit and opt-in:
209209

210210
- `Invoke-NovaBuild -ContinuousIntegration` re-imports the freshly built module after the build succeeds
211211
- `Update-NovaModuleVersion -ContinuousIntegration` re-imports the built module before the bump workflow starts
212+
- `Update-NovaModuleVersion -ContinuousIntegration` also falls back to a patch bump when the current `HEAD` already
213+
matches the latest tag, so release automation can seed the next prerelease line without requiring an extra commit
214+
first
212215
- `Publish-NovaModule -ContinuousIntegration` restores the built module after publish completes
213216
- `Invoke-NovaRelease -ContinuousIntegration` forwards that CI intent through the nested build/bump boundaries and then
214217
restores the built module again after publish
@@ -595,6 +598,11 @@ Responsibilities currently covered by the release pipeline include:
595598
- creating GitHub releases
596599
- publishing to PowerShell Gallery
597600

601+
The semantic-release publish script also bootstraps the local PSResourceGet repository store before calling
602+
`Publish-PSResource`, which keeps fresh GitHub Actions runners from failing when the PSGallery repository registration
603+
file
604+
does not exist yet.
605+
598606
### Where NovaModuleTools cmdlets fit
599607

600608
NovaModuleTools already provides strong release building blocks:

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"ProjectName": "NovaModuleTools",
33
"Description": "NovaModuleTools is an enterprise-focused evolution of ModuleTools, designed for large-scale PowerShell projects with a strong emphasis on structure, maintainability, and automated CI/CD pipelines.",
4-
"Version": "2.0.0",
4+
"Version": "2.0.0-beta06",
55
"Preamble": [
66
"Set-StrictMode -Version Latest",
77
"$ErrorActionPreference = 'Stop'"

scripts/release/Publish-ToPSGallery.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ param(
44
)
55

66
Set-StrictMode -Version Latest
7+
$ErrorActionPreference = 'Stop'
8+
9+
$scriptRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
10+
. (Join-Path $scriptRoot 'SemanticReleaseSupport.ps1')
711

812
if ([string]::IsNullOrWhiteSpace($ApiKey)) {
913
throw 'PSGALLERY_API environment variable is required.'
@@ -13,4 +17,5 @@ if (-not (Test-Path -LiteralPath $ModulePath)) {
1317
throw "Module path not found: $ModulePath"
1418
}
1519

16-
Publish-PSResource -Path $ModulePath -Repository PSGallery -ApiKey $ApiKey -Verbose
20+
Initialize-PSGalleryRepository
21+
Publish-PSResource -Path $ModulePath -Repository PSGallery -ApiKey $ApiKey -Verbose -ErrorAction Stop

scripts/release/SemanticReleaseSupport.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ $script:supportRoot = Join-Path (Split-Path -Parent $MyInvocation.MyCommand.Path
44
$script:supportFileList = @(
55
'Get-ReleaseDateString.ps1'
66
'Get-ReleaseRepositoryUrl.ps1'
7+
'Get-PSResourceRepositoryStoreDirectory.ps1'
8+
'Initialize-PSGalleryRepository.ps1'
79
'ConvertTo-ReleaseTagName.ps1'
810
'Read-JsonFile.ps1'
911
'Write-JsonFile.ps1'
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
function Get-PSResourceRepositoryStoreDirectory {
2+
[CmdletBinding()]
3+
param()
4+
5+
return Join-Path $HOME '.local/share/PSResourceGet'
6+
}
7+
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function Initialize-PSGalleryRepository {
2+
[CmdletBinding()]
3+
param()
4+
5+
$storeDirectory = Get-PSResourceRepositoryStoreDirectory
6+
if (-not (Test-Path -LiteralPath $storeDirectory)) {
7+
New-Item -ItemType Directory -Path $storeDirectory -Force | Out-Null
8+
}
9+
10+
if ($null -eq (Get-PSResourceRepository -Name PSGallery -ErrorAction SilentlyContinue)) {
11+
Register-PSResourceRepository -PSGallery
12+
}
13+
}
14+

src/private/release/GetNovaVersionLabelForBump.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ function Get-NovaVersionLabelForBump {
22
[CmdletBinding()]
33
param(
44
[Parameter(Mandatory)][string]$ProjectRoot,
5-
[string[]]$CommitMessages = @()
5+
[string[]]$CommitMessages = @(),
6+
[switch]$ContinuousIntegrationRequested
67
)
78

89
if ($CommitMessages.Count -gt 0) {
@@ -18,6 +19,10 @@ function Get-NovaVersionLabelForBump {
1819
}
1920

2021
if (-not (Test-GitRepositoryHasCommitsSinceLatestTag -ProjectRoot $ProjectRoot)) {
22+
if ($ContinuousIntegrationRequested) {
23+
return 'Patch'
24+
}
25+
2126
Stop-NovaOperation -Message 'Cannot bump version because there are no commits since the latest tag.' -ErrorId 'Nova.Workflow.NoCommitsSinceLatestTag' -Category InvalidOperation -TargetObject $ProjectRoot
2227
}
2328

src/private/release/GetNovaVersionUpdateWorkflowContext.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Get-NovaVersionUpdateWorkflowContext {
88

99
$projectInfo = Get-NovaProjectInfo -Path $ProjectRoot
1010
$commitMessages = @(Get-GitCommitMessageForVersionBump -ProjectRoot $ProjectRoot)
11-
$label = Get-NovaVersionLabelForBump -ProjectRoot $ProjectRoot -CommitMessages $commitMessages
11+
$label = Get-NovaVersionLabelForBump -ProjectRoot $ProjectRoot -CommitMessages $commitMessages -ContinuousIntegrationRequested:$ContinuousIntegrationRequested
1212
$versionUpdatePlan = Get-NovaVersionUpdatePlan -ProjectInfo $projectInfo -Label $label -PreviewRelease:$PreviewRelease
1313

1414
return Get-NovaVersionUpdateWorkflowContextObject -ProjectRoot $ProjectRoot -ProjectInfo $projectInfo -CommitMessages $commitMessages -Label $label -VersionUpdatePlan $versionUpdatePlan -PreviewRelease:$PreviewRelease -ContinuousIntegrationRequested:$ContinuousIntegrationRequested

tests/CoverageGaps.ReleaseInternals.Tests.ps1

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,33 @@ Describe 'Coverage gaps for release and git internals' {
620620
}
621621
}
622622

623+
It 'Get-NovaVersionLabelForBump returns Patch in CI mode when the current head already matches the latest tag' {
624+
InModuleScope $script:moduleName {
625+
$projectRoot = Join-Path $TestDrive 'mocked-ci-git-state'
626+
New-Item -ItemType Directory -Path (Join-Path $projectRoot '.git') -Force | Out-Null
627+
628+
Mock Invoke-NovaGitCommand {
629+
switch ($Arguments[0]) {
630+
'rev-parse' {
631+
return [pscustomobject]@{ExitCode = 0; Output = @('.git')}
632+
}
633+
'describe' {
634+
return [pscustomobject]@{ExitCode = 0; Output = @('v1.0.0')}
635+
}
636+
'rev-list' {
637+
return [pscustomobject]@{ExitCode = 0; Output = @('0')}
638+
}
639+
default {
640+
throw "Unexpected git args: $( $Arguments -join ' ' )"
641+
}
642+
}
643+
}
644+
645+
Get-NovaVersionLabelForBump -ProjectRoot $projectRoot -ContinuousIntegrationRequested | Should -Be 'Patch'
646+
Assert-MockCalled Invoke-NovaGitCommand -Times 1 -ParameterFilter {$Arguments[0] -eq 'rev-list' -and $Arguments[2] -eq 'v1.0.0..HEAD'}
647+
}
648+
}
649+
623650
It 'Get-NovaVersionLabelForBump returns Patch when the repository has commits but no tags yet' {
624651
InModuleScope $script:moduleName {
625652
$projectRoot = Join-Path $TestDrive 'mocked-git-without-tags'

0 commit comments

Comments
 (0)