function Update-ModuleMeta { <# .SYNOPSIS Updates the module manifest file fields to prepare the new build. .DESCRIPTION Replaces the version fields in the manifest file. Uses Drone env vars populated by pushed tags. .INPUTS [None] No pipeline input. .OUTPUTS [None] No pipeline output. .EXAMPLE Import-Module -Name DroneHelper; Update-ModuleMeta #> [CmdletBinding()] [OutputType()] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseConsistentWhitespace', '', Justification = 'Hashtable bug in ScriptAnalyzer 1.19.1' )] [Diagnostics.CodeAnalysis.SuppressMessageAttribute( 'PSUseShouldProcessForStateChangingFunctions', '', Justification = 'system state does not change permanent in temp build clients.' )] param () process { if ($Env:DRONE) { $Repo = Get-RepoPath if ($Env:DRONE_BUILD_EVENT -eq 'tag') { if ($null -ne $Env:DRONE_SEMVER) { $nVersion = $Env:DRONE_SEMVER_SHORT if ($null -ne $Env:DRONE_SEMVER_PRERELEASE) { $nPreRelease = $Env:DRONE_SEMVER_PRERELEASE } $ModManifestParams = @{ Path = $Repo.Src.Manifest.Item.FullName ModuleVersion = $nVersion ErrorAction = 'Stop' } if ($nPreRelease) { $ModManifestParams.PreRelease = $nPreRelease } $ManifestData = Test-ModuleManifest -Path $Repo.Src.Manifest.Item.FullName if ( ($nVersion -ne $ManifestData.Version) -or ($nVersion -ne $ManifestData.PrivateData.PSData.Prerelease) ) { Update-ModuleManifest @ModManifestParams } else { Write-Verbose -Message 'Identical version given. Skipping update.' } } else { Write-Verbose -Message 'Could not read the new Tag / Semver!' } } else { Write-Verbose -Message 'This pipeline was not triggered by a tag.' } } else { Write-Verbose -Message 'Running outside of drone.io pipeline. Skipping module update!' } } }