|
2 | 2 | param( |
3 | 3 | [Parameter(Mandatory = $true, HelpMessage = "Provide the version number in the format 'X.Y.Z', e.g., '3.0.0'.")] |
4 | 4 | [string]$VersionNumber, |
| 5 | + |
5 | 6 | [Parameter(Mandatory = $true)] |
6 | 7 | [bool]$IsPreview |
7 | 8 | ) |
8 | 9 |
|
9 | | -# Validate the input format |
| 10 | +# Validate version number format X.Y.Z |
10 | 11 | if ($VersionNumber -notmatch '^\d+\.\d+\.\d+$') { |
11 | | - Write-Host "Error: Version number must be in the format 'X.Y.Z', e.g., '3.0.0'." -ForegroundColor Red |
| 12 | + Write-Host "❌ Error: Version number must be in the format 'X.Y.Z', e.g., '3.0.0'." -ForegroundColor Red |
12 | 13 | exit 1 |
13 | 14 | } |
14 | 15 |
|
15 | | -# Generate PreviewVersion dynamically |
16 | | -$Timestamp = (Get-Date -Format "ddMMyy") |
17 | | -$Time = (Get-Date -Format "HHmm") |
18 | | -$PreviewVersion = "$Timestamp.$Time" |
| 16 | +# Build preview suffix (valid SemVer identifiers, no leading zeros) |
| 17 | +$DatePart = (Get-Date -Format "yyyyMMdd") # e.g. 20250822 |
| 18 | +$TimePart = (Get-Date -Format "Hmm") # e.g. 845 (not 0845, no leading zero!) |
| 19 | +$PreviewId = "$DatePart.$TimePart" # → "20250822.845" |
19 | 20 |
|
20 | | -# Construct the tag and message dynamically |
| 21 | +# Construct the tag |
21 | 22 | if ($IsPreview) { |
22 | | - $TagName = "v$VersionNumber-preview$PreviewVersion" |
| 23 | + # format: vX.Y.Z-preview.YYYYMMDD.HHmm |
| 24 | + $TagName = "v$VersionNumber-preview.$PreviewId" |
23 | 25 | } else { |
24 | 26 | $TagName = "v$VersionNumber" |
25 | 27 | } |
26 | 28 | $Message = "Release version $TagName" |
27 | 29 |
|
28 | | -# Display confirmation prompt |
29 | | -Write-Host "You are about to release:" -ForegroundColor Yellow |
30 | | -Write-Host "Tag: $TagName" -ForegroundColor Cyan |
31 | | -Write-Host "Message: $Message" -ForegroundColor Cyan |
| 30 | +# Confirm with user |
| 31 | +Write-Host "🚀 You are about to release:" -ForegroundColor Yellow |
| 32 | +Write-Host " Tag: $TagName" -ForegroundColor Cyan |
| 33 | +Write-Host " Message: $Message" -ForegroundColor Cyan |
32 | 34 | $response = Read-Host "Are you sure you want to proceed? (yes/no)" |
33 | 35 |
|
34 | 36 | if ($response -ne "yes") { |
35 | | - Write-Host "Release canceled by the user." -ForegroundColor Red |
| 37 | + Write-Host "❌ Release canceled by the user." -ForegroundColor Red |
36 | 38 | exit 0 |
37 | 39 | } |
38 | 40 |
|
39 | | -# Execute the git commands |
40 | | -Write-Host "Creating tag $TagName with message: $Message" |
| 41 | +# Git commands |
| 42 | +Write-Host "🔖 Creating tag $TagName with message: $Message" |
41 | 43 | git tag -a $TagName -m $Message |
42 | 44 |
|
43 | | -Write-Host "Pushing tag $TagName to origin" |
| 45 | +Write-Host "⬆️ Pushing tag $TagName to origin" |
44 | 46 | git push origin $TagName |
45 | 47 |
|
46 | | -Write-Host "Tag $TagName pushed successfully." -ForegroundColor Green |
| 48 | +Write-Host "✅ Tag $TagName pushed successfully." -ForegroundColor Green |
0 commit comments