Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
81a86bf
Considering the environment variable 'ModuleVersion' if it exists
raandree Jun 7, 2025
692c653
Added support for GitVersion which is a breaking change
raandree Jun 8, 2025
2b8f59e
Updated launch configs
raandree Jun 8, 2025
99479fa
Adapting tests to work with GitVersion 6
raandree Jun 9, 2025
6299f48
Updated changelog
raandree Jun 9, 2025
a41082d
Change deployment mode from ContinuousDelivery to ManualDeployment
raandree Jun 9, 2025
0123d68
Updated changelog
raandree Jun 9, 2025
4aa295c
Fixed typo
raandree Jun 9, 2025
47d551b
Merge branch 'main' into feature/gitversion6
raandree Jul 22, 2025
465ac5a
Changes according to the code review
raandree Jul 24, 2025
df5d0d2
Added test to check for environment variable
raandree Jul 24, 2025
2803e70
Merge branch 'main' into feature/gitversion6
raandree Jul 24, 2025
b8d2089
Merge branch 'main' into feature/gitversion6
raandree Aug 19, 2025
b5e990e
Fix Script Analyzer QA tests failing in various scripts (#540)
johlju Sep 2, 2025
566ae41
Add mac setup instructions to README (#532)
Mynster9361 Sep 5, 2025
cf68ca5
Fixed issue with changelog check (#541)
Ligtorn Sep 6, 2025
96ac6d8
fixing http.sslbackend schannel command because it failed
gaelcolas Jan 7, 2026
771695c
updating changelog
gaelcolas Jan 7, 2026
ba01456
Updating ChangeLog since v0.119.0 +semver:skip (#548)
gaelcolas Jan 8, 2026
b611786
fixing http.sslbackend schannel command because it failed
gaelcolas Jan 28, 2026
5e2beaa
Fix Gallery Preview Badge
dan-hughes Feb 11, 2026
a4282b1
Update PublishCodeCoverage to v2 (#552)
dan-hughes Mar 30, 2026
3a4c84d
New pack task using PSResourceGet (#555)
gaelcolas Mar 31, 2026
d103ae2
Moved large parts of the ReadMe to the Wiki (#488)
DennisL68 Mar 31, 2026
14fd4c8
Updated comment based help for Resolve-Dependency.ps1 (#537)
ahpooch Mar 31, 2026
1dd4128
Considering the environment variable 'ModuleVersion' if it exists
raandree Jun 7, 2025
4bf20fa
Added support for GitVersion which is a breaking change
raandree Jun 8, 2025
108a7c2
Updated launch configs
raandree Jun 8, 2025
b735a45
Adapting tests to work with GitVersion 6
raandree Jun 9, 2025
0f0e234
Updated changelog
raandree Jun 9, 2025
726a060
Change deployment mode from ContinuousDelivery to ManualDeployment
raandree Jun 9, 2025
2964b55
Fixed typo
raandree Jun 9, 2025
6482676
Changes according to the code review
raandree Jul 24, 2025
7cbcc04
Added test to check for environment variable
raandree Jul 24, 2025
95e5ff7
Merge branch 'feature/gitversion6' of https://github.com/raandree/Sam…
raandree Apr 18, 2026
29103ae
fix: correct GitVersion 6 config for version bump regexes and feature…
raandree Apr 18, 2026
3e471ce
```
raandree Apr 18, 2026
75aaff7
test: add stubs for gitversion in environment variable tests
raandree Apr 18, 2026
6498e50
fix: standardize formatting of RequiredModules.psd1 entries
raandree Apr 20, 2026
f823e38
fix(gitversion): skip AzDo pipeline variable writes when not running …
raandree Apr 21, 2026
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
197 changes: 197 additions & 0 deletions .build/tasks/Changelog.changelogmanagement.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
<#
.SYNOPSIS
Tasks for releasing modules.

.PARAMETER OutputDirectory
The base directory of all output. Defaults to folder 'output' relative to
the $BuildRoot.

.PARAMETER BuiltModuleSubdirectory
The parent path of the module to be built.

.PARAMETER VersionedOutputDirectory
If the module should be built using a version folder, e.g. ./MyModule/1.0.0.
Defaults to $true.

.PARAMETER ChangelogPath
The path to and the name of the changelog file. Defaults to 'CHANGELOG.md'.

.PARAMETER ReleaseNotesPath
The path to and the name of the release notes file. Defaults to 'ReleaseNotes.md'.

.PARAMETER ProjectName
The project name.

.PARAMETER ModuleVersion
The module version that was built.

.PARAMETER GalleryApiToken
The API token that gives permission to publish to the gallery.

.PARAMETER NuGetPublishSource
The source to publish nuget packages. Defaults to https://www.powershellgallery.com.

.PARAMETER PSModuleFeed
The name of the feed (repository) that is passed to command Publish-Module.
Defaults to 'PSGallery'.

.PARAMETER SkipPublish
If publishing should be skipped. Defaults to $false.

.PARAMETER PublishModuleWhatIf
If the publish command will be run with '-WhatIf' to show what will happen
during publishing. Defaults to $false.
#>

param
(
[Parameter()]
[string]
$OutputDirectory = (property OutputDirectory (Join-Path $BuildRoot 'output')),

[Parameter()]
[System.String]
$BuiltModuleSubdirectory = (property BuiltModuleSubdirectory ''),

[Parameter()]
[System.Management.Automation.SwitchParameter]
$VersionedOutputDirectory = (property VersionedOutputDirectory $true),

[Parameter()]
$ChangelogPath = (property ChangelogPath 'CHANGELOG.md'),

[Parameter()]
$ReleaseNotesPath = (property ReleaseNotesPath (Join-Path $OutputDirectory 'ReleaseNotes.md')),

[Parameter()]
[string]
$ProjectName = (property ProjectName ''),

[Parameter()]
[System.String]
$ModuleVersion = (property ModuleVersion ''),

[Parameter()]
[string]
$GalleryApiToken = (property GalleryApiToken ''),

[Parameter()]
[string]
$NuGetPublishSource = (property NuGetPublishSource 'https://www.powershellgallery.com/'),

[Parameter()]
$PSModuleFeed = (property PSModuleFeed 'PSGallery'),

[Parameter()]
$SkipPublish = (property SkipPublish ''),

[Parameter()]
$PublishModuleWhatIf = (property PublishModuleWhatIf '')
)

# Synopsis: Create ReleaseNotes from changelog and update the Changelog for release
task Create_changelog_release_output {
# Get the values for task variables, see https://github.com/gaelcolas/Sampler?tab=readme-ov-file#build-task-variables.
. Set-SamplerTaskVariable

$ChangeLogOutputPath = Get-SamplerAbsolutePath -Path 'CHANGELOG.md' -RelativeTo $OutputDirectory

"`tChangeLogOutputPath = '$ChangeLogOutputPath'"

# Parse the Changelog and extract unreleased
try
{
Import-Module ChangelogManagement -ErrorAction Stop

# Update the source changelog file
Write-Build DarkGray "`tCreating '$ChangeLogOutputPath'..."
Update-Changelog -Path $ChangeLogPath -OutputPath $ChangeLogOutputPath -ErrorAction Stop -ReleaseVersion $ModuleVersion -LinkMode none

# Get the updated CHANGELOG.md
$changeLogData = Get-ChangelogData -Path $ChangeLogOutputPath

# Filter out the latest module version change log entries
$changeLogDataForLatestRelease = $changeLogData.Released | Where-Object -FilterScript {
$_.Version -eq $ModuleVersion
}

<#
Get the raw markdown release notes for the module manifest. The
module manifest release notes has a hard size limit when publishing
to PowerShell Gallery.
#>
if ($changeLogDataForLatestRelease.RawData.Length -gt 10000)
{
$moduleManifestReleaseNotes = $changeLogDataForLatestRelease.RawData.Substring(0, 10000)
}
else
{
$moduleManifestReleaseNotes = $changeLogDataForLatestRelease.RawData
}

# Create a ReleaseNotes from the Updated changelog
ConvertFrom-Changelog -Path $ChangeLogOutputPath -Format Release -NoHeader -OutputPath $ReleaseNotesPath -ErrorAction Stop
}
catch
{
Write-Build Red "Error creating the Changelog Output and/or ReleaseNotes. $($_.Exception.Message)"
}

if (-not ($ReleaseNotes = (Get-Content -raw $ReleaseNotesPath -ErrorAction SilentlyContinue)))
{
$ReleaseNotes = Get-Content -raw $ChangeLogOutputPath -ErrorAction SilentlyContinue
}

if ($ReleaseNotes -and -not [string]::IsNullOrEmpty($builtModuleManifest) -and (Test-Path -Path $builtModuleManifest -ErrorAction SilentlyContinue))
{
try
{
Import-Module Configuration -ErrorAction Stop
}
catch
{
Write-Build Red "Issue importing Configuration module. $($_.Exception.Message)"
return
}

Write-Build DarkGray "Built Manifest $builtModuleManifest"
# No need to test the manifest again here, because the pipeline tested all manifests via the where-clause already

# Uncomment release notes (the default in Plaster/New-ModuleManifest)
$ManifestString = Get-Content -raw $builtModuleManifest
if ( $ManifestString -match '#\sReleaseNotes\s?=')
{
$ManifestString = $ManifestString -replace '#\sReleaseNotes\s?=', ' ReleaseNotes ='
$Utf8NoBomEncoding = [System.Text.UTF8Encoding]::new($False)
[System.IO.File]::WriteAllLines($BuiltModuleManifest, $ManifestString, $Utf8NoBomEncoding)
}

$UpdateReleaseNotesParams = @{
Path = $builtModuleManifest
PropertyName = 'PrivateData.PSData.ReleaseNotes'
Value = $moduleManifestReleaseNotes
ErrorAction = 'SilentlyContinue'
}

Update-Manifest @UpdateReleaseNotesParams
}
else
{
if ([string]::IsNullOrEmpty($ReleaseNotes))
{
Write-Build -Color Red "No Release notes found to insert."
}

if ([string]::IsNullOrEmpty($builtModuleManifest) -or -not (Test-Path -Path $builtModuleManifest))
{
if ([string]::IsNullOrEmpty($ProjectName))
{
Write-Build -Color DarkGray "No PowerShell module name found. We assume you are not building a PowerShell Module."
}
else
{
Write-Build -Color Red "No valid manifest found for project '$ProjectName'. Cannot update the Release Notes."
}
}
}
}
4 changes: 2 additions & 2 deletions .build/tasks/Create_Changelog_Branch.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ task Create_Changelog_Branch {
}

# Track this branch on the remote 'origin
$pullArguments += @('-c', 'http.sslbackend="schannel"', 'pull', 'origin', $MainGitBranch, '--tag')
$pullArguments += @('-c', 'http.sslbackend=schannel', 'pull', 'origin', $MainGitBranch, '--tag')

Sampler\Invoke-SamplerGit -Argument $pullArguments

Expand Down Expand Up @@ -238,7 +238,7 @@ task Create_Changelog_Branch {
}

# Track this branch on the remote 'origin
$pushArguments += @('-c', 'http.sslbackend="schannel"', 'push', '-u', 'origin', $BranchName)
$pushArguments += @('-c', 'http.sslbackend=schannel', 'push', '-u', 'origin', $BranchName)

Sampler\Invoke-SamplerGit -Argument $pushArguments

Expand Down
2 changes: 1 addition & 1 deletion .build/tasks/Create_Release_Git_Tag.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ task Create_Release_Git_Tag {
$pushArguments += @('-c', ('http.extraheader="AUTHORIZATION: basic {0}"' -f $patBase64))
}

$pushArguments += @('-c', 'http.sslbackend="schannel"', 'push', 'origin', '--tags')
$pushArguments += @('-c', 'http.sslbackend=schannel', 'push', 'origin', '--tags')

Sampler\Invoke-SamplerGit -Argument $pushArguments

Expand Down
1 change: 1 addition & 0 deletions .build/tasks/DeployAll.PSDeploy.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ param (

# Synopsis: Deploy everything configured in PSDeploy
task Deploy_with_PSDeploy {
Write-Warning -Message 'DEPRECATED: Support for PSDeploy will be removed in a future Sampler release.'
if ([System.String]::IsNullOrEmpty($ProjectName))
{
$ProjectName = Get-SamplerProjectName -BuildRoot $BuildRoot
Expand Down
61 changes: 61 additions & 0 deletions .build/tasks/GitVersion.build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
task GitVersion -if (Get-Command -Name dotnet-gitversion.exe, gitversion.exe -ErrorAction SilentlyContinue) {

$command = if (Get-Command -Name gitversion.exe -ErrorAction SilentlyContinue)
{
Write-Host 'Using gitversion.exe...'
'gitversion.exe'
}
elseif (Get-Command -Name dotnet-gitversion -ErrorAction SilentlyContinue)
{
Write-Host 'Using dotnet-gitversion...'
'dotnet-gitversion'
}
else
{
Write-Error 'Neither gitversion.exe nor dotnet-gitversion is available.'
return
}

$gitVersionObject = & $command
Write-Host -------------- GitVersion Outout --------------
$gitVersionObject | Write-Host
Write-Host -----------------------------------------------

$gitVersionObject = $gitVersionObject | ConvertFrom-Json
$longestKeyLength = ($gitVersionObject | Get-Member -MemberType NoteProperty | Select-Object -ExpandProperty Name | Sort-Object { $_.Length } | Select-Object -Last 1).Length
$gitVersionObject.PSObject.Properties.ForEach{
Write-Host -Object ("Setting Task Variable {0,-$longestKeyLength} with value '{1}'." -f $_.Name, $_.Value)
}

$isPreRelease = [bool]$gitVersionObject.PreReleaseLabel
$versionElements = $gitVersionObject.MajorMinorPatch

if ($isPreRelease)
{
if ($gitVersionObject.BranchName -eq 'main')
{
$nextPreReleaseNumber = $gitVersionObject.PreReleaseNumber
$paddedNextPreReleaseNumber = '{0:D4}' -f $nextPreReleaseNumber

$versionElements += $gitVersionObject.PreReleaseLabelWithDash
$versionElements += $paddedNextPreReleaseNumber
}
else
{
$versionElements += $gitVersionObject.PreReleaseLabelWithDash
$versionElements += '.' + $gitVersionObject.CommitsSinceVersionSource
}
}

$versionString = -join $versionElements
[System.Environment]::SetEnvironmentVariable('ModuleVersion', $versionString, 'Process')

if ([string]::IsNullOrEmpty($env:TF_BUILD)) #when the code runs on an AzDo build agent, the TF_BUILD variable is set
{
Write-Host "Writing version string '$versionString' to build / environment variable 'VersionString'."
Write-Host "##vso[task.setvariable variable=VersionString;]$($versionString)"

Write-Host "Updating build number to '$versionString'."
Write-Host "##vso[build.updatebuildnumber]$($versionString)"
}
}
Loading