Skip to content

Commit fb6d2a5

Browse files
Merge main into wildcard version fix
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
2 parents 0287cee + 1653be8 commit fb6d2a5

109 files changed

Lines changed: 2488 additions & 714 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/actions/Build-PSModule/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@ runs:
4040
PSMODULE_BUILD_PSMODULE_INPUT_OutputFolder: ${{ inputs.OutputFolder }}
4141
PSMODULE_BUILD_PSMODULE_INPUT_Version: ${{ inputs.Version }}
4242
PSMODULE_BUILD_PSMODULE_INPUT_Prerelease: ${{ inputs.Prerelease }}
43-
run: |
44-
# Build-PSModule
45-
${{ github.action_path }}/src/main.ps1
43+
run: ${{ github.action_path }}/src/main.ps1
4644

4745
- name: Upload module artifact
4846
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/actions/Build-PSModule/src/helpers/Build/Add-ContentFromItem.ps1

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function Add-ContentFromItem {
1+
function Add-ContentFromItem {
22
<#
33
.SYNOPSIS
44
Add the content of a folder or file to the root module file.
@@ -22,13 +22,10 @@
2222
[Parameter(Mandatory)]
2323
[string] $RootPath
2424
)
25-
# Get the path separator for the current OS
26-
$pathSeparator = [System.IO.Path]::DirectorySeparatorChar
25+
$separators = [char[]]@([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)
2726

28-
$relativeFolderPath = $Path -replace $RootPath, ''
29-
$relativeFolderPath = $relativeFolderPath -replace $file.Extension, ''
30-
$relativeFolderPath = $relativeFolderPath.TrimStart($pathSeparator)
31-
$relativeFolderPath = $relativeFolderPath -split $pathSeparator | ForEach-Object { "[$_]" }
27+
$relativeFolderPath = [System.IO.Path]::GetRelativePath($RootPath, $Path)
28+
$relativeFolderPath = $relativeFolderPath.Split($separators, [System.StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object { "[$_]" }
3229
$relativeFolderPath = $relativeFolderPath -join ' - '
3330

3431
Add-Content -Path $RootModuleFilePath -Force -Value @"
@@ -37,11 +34,11 @@ Write-Debug "[`$scriptName] - $relativeFolderPath - Processing folder"
3734
"@
3835

3936
$files = $Path | Get-ChildItem -File -Force -Filter '*.ps1' | Sort-Object -Property FullName
37+
4038
foreach ($file in $files) {
41-
$relativeFilePath = $file.FullName -replace $RootPath, ''
42-
$relativeFilePath = $relativeFilePath -replace $file.Extension, ''
43-
$relativeFilePath = $relativeFilePath.TrimStart($pathSeparator)
44-
$relativeFilePath = $relativeFilePath -split $pathSeparator | ForEach-Object { "[$_]" }
39+
$relativeFilePath = [System.IO.Path]::GetRelativePath($RootPath, $file.FullName)
40+
$relativeFilePath = [System.IO.Path]::ChangeExtension($relativeFilePath, $null).TrimEnd('.')
41+
$relativeFilePath = $relativeFilePath.Split($separators, [System.StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object { "[$_]" }
4542
$relativeFilePath = $relativeFilePath -join ' - '
4643

4744
Add-Content -Path $RootModuleFilePath -Force -Value @"

.github/actions/Build-PSModule/src/helpers/Build/Build-PSModuleRootModule.ps1

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@
4848
[System.IO.DirectoryInfo] $ModuleOutputFolder
4949
)
5050

51-
# Get the path separator for the current OS
52-
$pathSeparator = [System.IO.Path]::DirectorySeparatorChar
51+
$separators = [char[]]@([System.IO.Path]::DirectorySeparatorChar, [System.IO.Path]::AltDirectorySeparatorChar)
5352

5453
Set-GitHubLogGroup 'Build root module' {
5554
$rootModuleFile = New-Item -Path $ModuleOutputFolder -Name "$ModuleName.psm1" -Force
@@ -185,22 +184,21 @@ Write-Debug "[$scriptName] - [data] - Done"
185184
)
186185

187186
foreach ($scriptFolder in $scriptFoldersToProcess) {
188-
$scriptFolder = Join-Path -Path $ModuleOutputFolder -ChildPath $scriptFolder
189-
if (-not (Test-Path -Path $scriptFolder)) {
187+
$scriptFolderPath = Join-Path -Path $ModuleOutputFolder -ChildPath $scriptFolder
188+
if (-not (Test-Path -Path $scriptFolderPath)) {
190189
continue
191190
}
192-
Add-ContentFromItem -Path $scriptFolder -RootModuleFilePath $rootModuleFile -RootPath $ModuleOutputFolder
193-
Remove-Item -Path $scriptFolder -Force -Recurse
191+
Add-ContentFromItem -Path $scriptFolderPath -RootModuleFilePath $rootModuleFile -RootPath $ModuleOutputFolder
192+
Remove-Item -Path $scriptFolderPath -Force -Recurse
194193
}
195194
#endregion - Add content from subfolders
196195

197196
#region - Add content from *.ps1 files on module root
198197
$files = $ModuleOutputFolder | Get-ChildItem -File -Force -Filter '*.ps1' | Sort-Object -Property FullName
199198
foreach ($file in $files) {
200-
$relativePath = $file.FullName -replace $ModuleOutputFolder, ''
201-
$relativePath = $relativePath -replace $file.Extension, ''
202-
$relativePath = $relativePath.TrimStart($pathSeparator)
203-
$relativePath = $relativePath -split $pathSeparator | ForEach-Object { "[$_]" }
199+
$relativePath = [System.IO.Path]::GetRelativePath($ModuleOutputFolder, $file.FullName)
200+
$relativePath = [System.IO.Path]::ChangeExtension($relativePath, $null).TrimEnd('.')
201+
$relativePath = $relativePath.Split($separators, [System.StringSplitOptions]::RemoveEmptyEntries) | ForEach-Object { "[$_]" }
204202
$relativePath = $relativePath -join ' - '
205203

206204
Add-Content -Path $rootModuleFile -Force -Value @"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Build-ZensicalSite
2+
3+
Builds Zensical documentation site output and normalizes it to `<working-directory>/_site`.
4+
5+
## Inputs
6+
7+
- `WorkingDirectory` (required): Build working directory.
8+
9+
## Usage
10+
11+
```yaml
12+
- name: Build documentation site with Zensical
13+
uses: ./_wf/.github/actions/Build-ZensicalSite
14+
with:
15+
WorkingDirectory: .
16+
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build-ZensicalSite
2+
description: Build Zensical site output and normalize output folder.
3+
4+
inputs:
5+
WorkingDirectory:
6+
description: Working directory for the repository build.
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Build documentation site
13+
shell: pwsh
14+
env:
15+
INPUT_WORKING_DIRECTORY: ${{ inputs.WorkingDirectory }}
16+
run: '& "${{ github.action_path }}/src/main.ps1" -WorkingDirectory "$env:INPUT_WORKING_DIRECTORY"'
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
param(
2+
[Parameter(Mandatory)]
3+
[string]$WorkingDirectory
4+
)
5+
6+
$ErrorActionPreference = 'Stop'
7+
8+
$resolvedWorkingDirectory = Resolve-Path -Path $WorkingDirectory | Select-Object -ExpandProperty Path
9+
$siteWorkingDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath 'outputs/site'
10+
$outputSitePath = Join-Path -Path $resolvedWorkingDirectory -ChildPath '_site'
11+
12+
Set-Location -Path $siteWorkingDirectory
13+
14+
if (-not (Test-Path -Path 'zensical.toml')) {
15+
throw "No documentation config file found in outputs/site. Expected zensical.toml."
16+
}
17+
18+
zensical build --config-file 'zensical.toml'
19+
20+
if (Test-Path -Path '_site') {
21+
if (Test-Path -Path $outputSitePath) {
22+
Remove-Item -Path $outputSitePath -Recurse -Force
23+
}
24+
Move-Item -Path '_site' -Destination $outputSitePath -Force
25+
}
26+
27+
if (-not (Test-Path -Path $outputSitePath)) {
28+
throw "Expected Zensical output at $outputSitePath but it was not created."
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#Requires -Version 7.0
2+
3+
<#
4+
.SYNOPSIS
5+
Builds the Zensical site and normalizes output to the expected _site path.
6+
7+
.DESCRIPTION
8+
Runs zensical build from outputs/site and moves the generated _site directory
9+
to <WorkingDirectory>/_site for downstream workflow steps.
10+
11+
.EXAMPLE
12+
./main.ps1 -WorkingDirectory '.'
13+
14+
.INPUTS
15+
None.
16+
17+
.OUTPUTS
18+
None.
19+
#>
20+
[CmdletBinding()]
21+
param(
22+
# Build working directory containing outputs/site and destination _site.
23+
[Parameter(Mandatory)]
24+
[string]$WorkingDirectory
25+
)
26+
27+
$ErrorActionPreference = 'Stop'
28+
29+
$resolvedWorkingDirectory = Resolve-Path -Path $WorkingDirectory | Select-Object -ExpandProperty Path
30+
$siteWorkingDirectory = Join-Path -Path $resolvedWorkingDirectory -ChildPath 'outputs/site'
31+
$outputSitePath = Join-Path -Path $resolvedWorkingDirectory -ChildPath '_site'
32+
33+
Set-Location -Path $siteWorkingDirectory
34+
35+
if (-not (Test-Path -Path 'zensical.toml')) {
36+
throw "No documentation config file found in outputs/site. Expected zensical.toml."
37+
}
38+
39+
zensical build --config-file 'zensical.toml'
40+
41+
if (Test-Path -Path '_site') {
42+
if (Test-Path -Path $outputSitePath) {
43+
Remove-Item -Path $outputSitePath -Recurse -Force
44+
}
45+
Move-Item -Path '_site' -Destination $outputSitePath -Force
46+
}
47+
48+
if (-not (Test-Path -Path $outputSitePath)) {
49+
throw "Expected Zensical output at $outputSitePath but it was not created."
50+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Cleanup-PSModulePrereleases
2+
description: Cleanup prerelease GitHub releases associated with the current pull request branch.
3+
author: PSModule
4+
5+
inputs:
6+
AutoCleanup:
7+
description: Control whether to automatically delete prerelease tags.
8+
required: false
9+
default: 'true'
10+
WhatIf:
11+
description: If specified, the action will only log the changes it would make.
12+
required: false
13+
default: 'false'
14+
WorkingDirectory:
15+
description: The working directory where the script will run from.
16+
required: false
17+
default: '.'
18+
19+
runs:
20+
using: composite
21+
steps:
22+
- name: Install-PSModule
23+
uses: ./_wf/.github/actions/Install-PSModule
24+
25+
- name: Cleanup Prereleases
26+
if: inputs.AutoCleanup == 'true' || inputs.WhatIf == 'true'
27+
shell: pwsh
28+
working-directory: ${{ inputs.WorkingDirectory }}
29+
env:
30+
PSMODULE_CLEANUP_PSMODULEPRERELEASES_INPUT_WhatIf: ${{ inputs.WhatIf }}
31+
PSMODULE_CLEANUP_PSMODULEPRERELEASES_CONTEXT_ReleaseTag: ${{ env.PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag }}
32+
run: ${{ github.action_path }}/src/cleanup.ps1

.github/actions/Publish-PSModule/src/cleanup.ps1 renamed to .github/actions/Cleanup-PSModulePrereleases/src/cleanup.ps1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ param()
33

44
$PSStyle.OutputRendering = 'Ansi'
55

6-
Import-Module -Name 'Helpers' -Force
6+
Import-Module -Name 'PSModule' -Force
77

88
#region Load inputs
99
LogGroup 'Load inputs' {
10-
$whatIf = $env:PSMODULE_PUBLISH_PSMODULE_INPUT_WhatIf -eq 'true'
10+
$whatIf = $env:PSMODULE_CLEANUP_PSMODULEPRERELEASES_INPUT_WhatIf -eq 'true'
1111

1212
$githubEventJson = Get-Content -Raw $env:GITHUB_EVENT_PATH
1313
$githubEvent = $githubEventJson | ConvertFrom-Json
@@ -27,7 +27,7 @@ LogGroup 'Load inputs' {
2727
Write-Host "Prerelease name: [$prereleaseName]"
2828
Write-Host "WhatIf: [$whatIf]"
2929

30-
$publishedReleaseTag = $env:PSMODULE_PUBLISH_PSMODULE_CONTEXT_ReleaseTag
30+
$publishedReleaseTag = $env:PSMODULE_CLEANUP_PSMODULEPRERELEASES_CONTEXT_ReleaseTag
3131
if (-not [string]::IsNullOrWhiteSpace($publishedReleaseTag)) {
3232
Write-Host "Published tag: [$publishedReleaseTag] (excluded from cleanup)"
3333
}

.github/actions/Document-PSModule/action.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,4 @@ runs:
2727
DOCUMENT_PSMODULE_INPUT_Name: ${{ inputs.Name }}
2828
DOCUMENT_PSMODULE_INPUT_ShowSummaryOnSuccess: ${{ inputs.ShowSummaryOnSuccess }}
2929
working-directory: ${{ inputs.WorkingDirectory }}
30-
run: |
31-
# Build-PSModuleDocumentation
32-
${{ github.action_path }}/src/main.ps1
30+
run: ${{ github.action_path }}/src/main.ps1

0 commit comments

Comments
 (0)