1717# - Tag does not already exist locally or on origin
1818
1919[CmdletBinding (SupportsShouldProcess , ConfirmImpact = ' High' )]
20+ # tools/tag-release.ps1
21+ [Diagnostics.CodeAnalysis.SuppressMessageAttribute (' PSAvoidUsingWriteHost' , ' ' ,
22+ Justification = ' Write-Host is required for colored interactive console output.' )]
2023param (
2124 [Parameter (Mandatory = $true , HelpMessage = ' Semantic version to tag, e.g. 1.0.0' )]
2225 [ValidatePattern (' ^[0-9]+\.[0-9]+\.[0-9]+$' )]
@@ -34,17 +37,17 @@ $ErrorActionPreference = 'Stop'
3437# ---------------------------------------------------------------------------
3538
3639function Write-Step ([string ]$Message ) {
37- Write-Output " $Message " - ForegroundColor Cyan
40+ Write-Host " $Message " - ForegroundColor Cyan
3841}
3942
4043function Write-Ok ([string ]$Message ) {
41- Write-Output " ok $Message " - ForegroundColor Green
44+ Write-Host " ok $Message " - ForegroundColor Green
4245}
4346
4447function Fail ([string ]$Message ) {
45- Write-Output " "
46- Write-Output " FAIL $Message " - ForegroundColor Red
47- Write-Output " "
48+ Write-Host " "
49+ Write-Host " FAIL $Message " - ForegroundColor Red
50+ Write-Host " "
4851 throw $Message
4952}
5053
@@ -67,13 +70,13 @@ $repoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path
6770$dataFile = Join-Path $repoRoot ' data' ' delphi-compiler-versions.json'
6871$tag = " v$Version "
6972
70- Write-Output " "
71- Write-Output " delphi-compiler-versions tag-release" - ForegroundColor White
72- Write-Output " ======================================" - ForegroundColor White
73- Write-Output " Version : $Version "
74- Write-Output " Tag : $tag "
75- Write-Output " Repo : $repoRoot "
76- Write-Output " "
73+ Write-Host " "
74+ Write-Host " delphi-compiler-versions tag-release" - ForegroundColor White
75+ Write-Host " ======================================" - ForegroundColor White
76+ Write-Host " Version : $Version "
77+ Write-Host " Tag : $tag "
78+ Write-Host " Repo : $repoRoot "
79+ Write-Host " "
7780
7881# ---------------------------------------------------------------------------
7982# Precondition 1: data file exists and is valid JSON
@@ -144,7 +147,7 @@ try {
144147 $defaultBranch = if ($LASTEXITCODE -eq 0 -and $originHead ) {
145148 $originHead.Trim () -replace ' ^origin/' , ' '
146149 } else {
147- Write-Output " warn origin/HEAD not set; assuming default branch is 'main'" - ForegroundColor Yellow
150+ Write-Host " warn origin/HEAD not set; assuming default branch is 'main'" - ForegroundColor Yellow
148151 ' main'
149152 }
150153
@@ -153,7 +156,7 @@ try {
153156 }
154157
155158 if ($SkipBranchCheck -and $branch -ne $defaultBranch ) {
156- Write-Output " warn Not on '$defaultBranch ' (on '$branch '); -SkipBranchCheck override active" - ForegroundColor Yellow
159+ Write-Host " warn Not on '$defaultBranch ' (on '$branch '); -SkipBranchCheck override active" - ForegroundColor Yellow
157160 } else {
158161 Write-Ok " on branch '$defaultBranch '"
159162 }
@@ -233,9 +236,9 @@ try {
233236 # All preconditions passed - confirm and tag
234237 # -------------------------------------------------------------------------
235238
236- Write-Output " "
237- Write-Output " All checks passed." - ForegroundColor Green
238- Write-Output " "
239+ Write-Host " "
240+ Write-Host " All checks passed." - ForegroundColor Green
241+ Write-Host " "
239242
240243 if ($PSCmdlet.ShouldProcess (
241244 " origin (tag: $tag message: '$tagMsg ')" ,
@@ -251,38 +254,38 @@ try {
251254 Invoke-Git push origin $tag | Out-Null
252255 Write-Ok " tag pushed"
253256
254- Write-Output " "
255- Write-Output " Released: $tag " - ForegroundColor Green
256- Write-Output " The GitHub Actions release workflow should run for this tag." - ForegroundColor Green
257- Write-Output " "
257+ Write-Host " "
258+ Write-Host " Released: $tag " - ForegroundColor Green
259+ Write-Host " The GitHub Actions release workflow should run for this tag." - ForegroundColor Green
260+ Write-Host " "
258261
259262 } catch {
260263
261- Write-Output " "
262- Write-Output " ERROR: Tag/push failed." - ForegroundColor Red
263- Write-Output $_ - ForegroundColor DarkRed
264- Write-Output " "
265- Write-Output " Partial failure - check the state and clean up if needed:" - ForegroundColor Yellow
264+ Write-Host " "
265+ Write-Host " ERROR: Tag/push failed." - ForegroundColor Red
266+ Write-Host $_ - ForegroundColor DarkRed
267+ Write-Host " "
268+ Write-Host " Partial failure - check the state and clean up if needed:" - ForegroundColor Yellow
266269
267270 & git show-ref -- tags -- verify -- quiet " refs/tags/$tag " 2> $null
268271 if ($LASTEXITCODE -eq 0 ) {
269- Write-Output " Local tag exists. If the push failed, delete it with:" - ForegroundColor Yellow
270- Write-Output " git tag -d $tag " - ForegroundColor Yellow
272+ Write-Host " Local tag exists. If the push failed, delete it with:" - ForegroundColor Yellow
273+ Write-Host " git tag -d $tag " - ForegroundColor Yellow
271274 }
272275
273- Write-Output " Verify origin does not have a partial push:" - ForegroundColor Yellow
274- Write-Output " git ls-remote --tags origin refs/tags/$tag " - ForegroundColor Yellow
275- Write-Output " "
276+ Write-Host " Verify origin does not have a partial push:" - ForegroundColor Yellow
277+ Write-Host " git ls-remote --tags origin refs/tags/$tag " - ForegroundColor Yellow
278+ Write-Host " "
276279 throw
277280
278281 }
279282
280283 } else {
281284 # -WhatIf was specified - echo what would happen without doing it
282- Write-Output " WhatIf: would create annotated tag and push to origin" - ForegroundColor Yellow
283- Write-Output " Tag : $tag " - ForegroundColor Yellow
284- Write-Output " Message: $tagMsg " - ForegroundColor Yellow
285- Write-Output " "
285+ Write-Host " WhatIf: would create annotated tag and push to origin" - ForegroundColor Yellow
286+ Write-Host " Tag : $tag " - ForegroundColor Yellow
287+ Write-Host " Message: $tagMsg " - ForegroundColor Yellow
288+ Write-Host " "
286289 }
287290
288291} finally {
0 commit comments