Skip to content

Commit 640c21e

Browse files
authored
Merge pull request #83 from Brownserve-UK/repo_cmdlets
Fix generated docs to keep them consistent
2 parents 6b62296 + 13d44d8 commit 640c21e

File tree

100 files changed

+1923
-271
lines changed

Some content is hidden

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

100 files changed

+1923
-271
lines changed

.build/build.ps1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ param
4040
)]
4141
[ValidateSet(
4242
'Build',
43+
'BuildAndImport',
44+
'BuildWithDocs',
4345
'BuildAndTest',
4446
'BuildTestAndCheck',
4547
'StageRelease',
4648
'Release'
4749
)]
4850
[AllowEmptyString()]
4951
[string]
50-
$Build = 'Build',
52+
$Build = 'BuildWithDocs',
5153

5254
# When preparing a release this denotes the type of changes that have been made.
5355
# This is used to determine the version number to use for the release.
@@ -63,6 +65,13 @@ param
6365
[string]
6466
$ReleaseType = 'minor',
6567

68+
# An optional release notice to include in the release
69+
[Parameter(
70+
Mandatory = $false
71+
)]
72+
[string]
73+
$ReleaseNotice,
74+
6675
# Where the module should be published to
6776
[Parameter(
6877
Mandatory = $false

.build/tasks/build_tasks.ps1

Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ param
5252
[string]
5353
$ReleaseType,
5454

55+
# An optional release notice to include in the release
56+
[Parameter(
57+
Mandatory = $false
58+
)]
59+
[string]
60+
$ReleaseNotice,
61+
5562
# The branch this is being built from
5663
[Parameter(
5764
Mandatory = $true
@@ -139,7 +146,6 @@ $script:NuspecPath = Join-Path $script:NugetPackageDirectory "$ModuleName.nuspec
139146
$script:GitHubRepoURI = "https://github.com/$GitHubRepoOwner/$GitHubRepoName"
140147
$Script:BuiltModulePath = (Join-Path $global:BrownserveBuiltModuleDirectory -ChildPath "$ModuleName.psd1")
141148
$script:TrackedFiles = @()
142-
$script:LineEndingFiles = @()
143149

144150
<#
145151
Work out if this is a production release depending on the branch we're building from
@@ -381,6 +387,10 @@ task CreateChangelogEntry SetVersion, {
381387
RepositoryName = $GitHubRepoName
382388
ChangelogObject = $script:Changelog
383389
}
390+
if ($ReleaseNotice)
391+
{
392+
$NewChangelogEntryParams.Add('Notice', $ReleaseNotice)
393+
}
384394
if ($GitHubStageReleaseToken)
385395
{
386396
$NewChangelogEntryParams.Add('Auto', $true)
@@ -419,7 +429,6 @@ task UpdateChangelog CreateChangelogEntry, {
419429
{
420430
throw "Failed to update changelog. `n$($_.Exception.Message)"
421431
}
422-
$script:LineEndingFiles += $script:ChangelogPath
423432
$script:TrackedFiles += ($script:ChangelogPath | Convert-Path)
424433
}
425434

@@ -611,11 +620,6 @@ task UpdateModuleDocumentation ImportModule, {
611620
Resolve-Path to fail.
612621
#>
613622
$Script:ModulePagePath = Join-Path $Global:BrownserveRepoDocsDirectory "$ModuleName.md" | Resolve-Path
614-
$script:LineEndingFiles += (Get-ChildItem `
615-
-Path (Join-Path $Global:BrownserveRepoDocsDirectory -ChildPath $ModuleName) `
616-
-Filter *.md `
617-
-Recurse | Select-Object -ExpandProperty 'FullName')
618-
$script:LineEndingFiles += (Get-Item -Path $Script:ModulePagePath)
619623
}
620624

621625
<#
@@ -684,33 +688,6 @@ task CompressModule CreateModuleHelp, {
684688
}
685689
}
686690

687-
<#
688-
.SYNOPSIS
689-
Ensures line endings for tracked files are set to 'LF'
690-
.DESCRIPTION
691-
PowerShell seems to insist on doing inconsistent things with line endings when running on different OSes.
692-
This results in constant line ending change diffs in git which fails the build.
693-
Therefore some files that are created as part of the build need to have their line endings set to 'LF' to ensure
694-
consistency.
695-
696-
!! This task has no dependencies as it should be run after all other tasks that may modify tracked files so be
697-
!! careful with where you place it in the build.
698-
#>
699-
task SetLineEndings {
700-
if ($script:LineEndingFiles.Count -gt 0)
701-
{
702-
Write-Build White 'Ensuring line endings are consistent'
703-
Set-LineEndings `
704-
-Path $script:LineEndingFiles `
705-
-LineEnding 'LF' `
706-
-ErrorAction 'Stop'
707-
}
708-
else
709-
{
710-
Write-Warning 'No tracked files were specified for line ending checks'
711-
}
712-
}
713-
714691
<#
715692
.SYNOPSIS
716693
Creates a new branch for staging the release
@@ -746,7 +723,7 @@ task CreateStagingBranch SetVersion, {
746723
For example when we update the changelog or module documentation before a release.
747724
We want to commit those changes so they get included in the release. (and don't fail the build later on)
748725
#>
749-
task CommitTrackedChanges UpdateChangelog, UpdateModuleDocumentation, CreateStagingBranch, SetLineEndings, {
726+
task CommitTrackedChanges UpdateChangelog, UpdateModuleDocumentation, CreateStagingBranch, {
750727
$CommitMessage = "docs: Prepare for $script:PrefixedVersion`n`nThis commit was automatically generated."
751728
if ($script:TrackedFiles.Count -gt 0)
752729
{
@@ -986,7 +963,7 @@ task PublishRelease CheckPreviousReleases, CompressModule, Tests, PackNuGetPacka
986963
if ('PSGallery' -in $PublishTo)
987964
{
988965
Write-Build White 'Pushing to PSGallery'
989-
<#
966+
<#
990967
For PSGallery the module needs to be in a directory named after itself... -_- (PowerShellGet is awful)
991968
2023-09-09: It gets EVEN MORE awful!
992969
It looks like PowerShellGet will automatically tag EVERY cmdlet which takes you over the 4000 NuGet character limit!!!
@@ -1020,7 +997,7 @@ task PublishRelease CheckPreviousReleases, CompressModule, Tests, PackNuGetPacka
1020997
$ReleaseParams.Add('TargetCommit', $script:CurrentCommitHash)
1021998
}
1022999
$ReleaseResponse = New-GitHubRelease @ReleaseParams
1023-
1000+
10241001
if ($script:CompressedModule)
10251002
{
10261003
Write-Build White 'Uploading compressed module as release asset'
@@ -1057,27 +1034,51 @@ task PublishRelease CheckPreviousReleases, CompressModule, Tests, PackNuGetPacka
10571034
.SYNOPSIS
10581035
Meta task for building the module.
10591036
.DESCRIPTION
1060-
This task will run all the tasks required to build the module.
1061-
This task is useful for local development as it allows you to import the module and test cmdlets etc.
1037+
This task will run all the tasks required to build just the module.
1038+
It doesn't build the documentation, NuGet package or perform any tests.
1039+
This task is mostly here just to serve as a base for other tasks.
1040+
#>
1041+
task Build UseWorkingCopy, CreateModuleManifest, {}
1042+
1043+
<#
1044+
.SYNOPSIS
1045+
Meta task for building the module and importing it.
1046+
.DESCRIPTION
1047+
This task will run all the tasks required to build the module and import it.
1048+
It does not build the documentation, NuGet package or perform any tests as these can take some time to complete.
1049+
This task is best used when developing new features locally as it allows you to quickly test your changes
1050+
interactively.
1051+
#>
1052+
task BuildAndImport Build, ImportModule, {}
1053+
1054+
<#
1055+
.SYNOPSIS
1056+
Meta task for building the module along with the documentation.
1057+
.DESCRIPTION
1058+
This task will run all the tasks required to build the module and generate the documentation.
1059+
The documentation can take some time to generate, especially as it currently requires us to run a separate process
1060+
to replace the line endings and format the markdown.
1061+
This task is best ran after any local changes have largely been finalised as it will generate any documentation
1062+
required.
10621063
#>
1063-
task Build UseWorkingCopy, CreateModuleManifest, UpdateModuleDocumentation, CreateModuleHelp, SetLineEndings, {}
1064+
task BuildWithDocs BuildAndImport, CreateModuleHelp, {}
10641065

10651066
<#
10661067
.SYNOPSIS
10671068
Meta task for building and testing the module.
10681069
.DESCRIPTION
1069-
This task will build the module and perform unit tests on it.
1070-
This task is useful for completing more thorough testing of the module when developing locally.
1070+
This task performs the same actions as the previous tasks but also performs unit tests on the module.
1071+
This task is best used to thoroughly test any changes before committing them.
10711072
#>
1072-
task BuildAndTest Build, Tests, {}
1073+
task BuildAndTest BuildWithDocs, Tests, {}
10731074

10741075
<#
10751076
.SYNOPSIS
10761077
Meta task for building and testing the module, then finally confirming there are no uncommitted changes.
10771078
.DESCRIPTION
10781079
This task will build the module, perform unit tests on it and then ensure there are no uncommitted changes
10791080
resulting from the build.
1080-
This is the build we use for our pull_request CI pipeline.
1081+
This is the build we use for our pull_request CI pipeline and as such must pass before we can merge any changes.
10811082
#>
10821083
task BuildTestAndCheck BuildAndTest, CheckForUncommittedChanges, {}
10831084

@@ -1090,7 +1091,7 @@ task BuildTestAndCheck BuildAndTest, CheckForUncommittedChanges, {}
10901091
This allows us to review the changes and make any adjustments before we actually release them.
10911092
We use this task in the stage_release CI pipeline.
10921093
#>
1093-
task StageRelease CheckStagingParameters, UseWorkingCopy, CreateChangelogEntry, UpdateChangelog, UpdateModuleDocumentation, UpdateModulePageHelpVersion, SetLineEndings, CreatePullRequest, {
1094+
task StageRelease CheckStagingParameters, UseWorkingCopy, CreateChangelogEntry, UpdateChangelog, UpdateModuleDocumentation, UpdateModulePageHelpVersion, CreatePullRequest, {
10941095
$BuildMessage = @"
10951096
The release has been successfully staged and a pull request has been created.
10961097
Please review the changes at $script:PRLink and merge if they look good.

.github/workflows/stage-release.yaml

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
- major
1313
- minor
1414
- patch
15+
notice:
16+
description: 'An optional notice to display on this release'
17+
required: false
18+
type: string
1519

1620
jobs:
1721
stage-release:
@@ -41,15 +45,21 @@ jobs:
4145
shell: pwsh
4246
env:
4347
GitHubPAT: ${{ secrets.AUTOMATED_BUILD_GITHUB_PAT }}
48+
ReleaseNotice: ${{ inputs.notice }}
4449
run: |
45-
./Brownserve.PSTools/.build/build.ps1 `
46-
-BranchName $env:GITHUB_REF `
47-
-GitHubRepoName 'Brownserve.PSTools' `
48-
-Build 'StageRelease' `
49-
-GitHubStageReleaseToken $env:GitHubPAT `
50-
-ReleaseType '${{ inputs.release_type}}' `
51-
-UseWorkingCopy `
52-
-Verbose
50+
$Params = @{
51+
BranchName = $env:GITHUB_REF
52+
GitHubRepoName = 'Brownserve.PSTools'
53+
Build = 'StageRelease'
54+
GitHubStageReleaseToken = $env:GitHubPAT
55+
ReleaseType = '${{ inputs.release_type}}'
56+
UseWorkingCopy = $true
57+
Verbose = $true
58+
}
59+
if ($env:ReleaseNotice) {
60+
$Params.Add('ReleaseNotice', $env:ReleaseNotice)
61+
}
62+
./Brownserve.PSTools/.build/build.ps1 @Params
5363
# Step 4: Push a notification to Slack
5464
- name: notify-slack
5565
shell: pwsh

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"isnot",
1919
"LASTEXITCODE",
2020
"MAML",
21+
"markdownlint",
2122
"Mddhhmm",
2223
"mrkdwn",
2324
"notcontains",
@@ -32,6 +33,7 @@
3233
"psobject",
3334
"pstools",
3435
"pwsh",
36+
"shoddyguard",
3537
"teamcity",
3638
"Teamcity",
3739
"TMPDIR",

0 commit comments

Comments
 (0)