Skip to content

Commit e84a0ef

Browse files
committed
ci(release): include beta notes in stable releases
1 parent 54223e8 commit e84a0ef

3 files changed

Lines changed: 95 additions & 3 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env pwsh
2+
[CmdletBinding()]
3+
param(
4+
[Parameter(Mandatory = $true)]
5+
[string] $Tag
6+
)
7+
8+
$ErrorActionPreference = 'Stop'
9+
10+
function Test-IsPrereleaseTag([string]$Tag) {
11+
return $Tag -like '*-*'
12+
}
13+
14+
$describeArgs = @('describe', '--tags', '--abbrev=0')
15+
if (-not (Test-IsPrereleaseTag -Tag $Tag)) {
16+
$describeArgs += @('--exclude', '*-*')
17+
}
18+
$describeArgs += "$Tag^"
19+
20+
$prevRef = & git @describeArgs 2>$null
21+
if ($LASTEXITCODE -eq 0 -and $prevRef) {
22+
$prevRef.Trim()
23+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
#!/usr/bin/env pwsh
2+
[CmdletBinding()]
3+
param()
4+
5+
$ErrorActionPreference = 'Stop'
6+
7+
$resolver = Join-Path $PSScriptRoot 'Resolve-ReleaseBaseTag.ps1'
8+
$repo = Join-Path ([System.IO.Path]::GetTempPath()) ("release-base-test-" + [System.Guid]::NewGuid().ToString('N'))
9+
10+
function Invoke-Git {
11+
param(
12+
[Parameter(Mandatory = $true)]
13+
[string[]] $Arguments
14+
)
15+
16+
& git @Arguments | Out-Null
17+
if ($LASTEXITCODE -ne 0) {
18+
throw "git $($Arguments -join ' ') failed with exit code $LASTEXITCODE"
19+
}
20+
}
21+
22+
function Add-TestCommit {
23+
param(
24+
[Parameter(Mandatory = $true)]
25+
[string] $Content,
26+
[Parameter(Mandatory = $true)]
27+
[string] $Subject
28+
)
29+
30+
Set-Content -LiteralPath (Join-Path $repo 'sample.txt') -Value $Content -Encoding UTF8
31+
Invoke-Git @('add', 'sample.txt')
32+
Invoke-Git @('commit', '-m', $Subject)
33+
}
34+
35+
try {
36+
New-Item -ItemType Directory -Path $repo -Force | Out-Null
37+
Push-Location $repo
38+
39+
Invoke-Git @('init', '-q')
40+
Invoke-Git @('config', 'user.email', 'release-test@example.com')
41+
Invoke-Git @('config', 'user.name', 'Release Test')
42+
43+
Add-TestCommit -Content 'base' -Subject 'chore: base'
44+
Invoke-Git @('tag', 'v2026.5.1.0')
45+
46+
Add-TestCommit -Content 'pre' -Subject 'feat: prerelease patch'
47+
Invoke-Git @('tag', 'v2026.5.2.0-beta')
48+
49+
Add-TestCommit -Content 'stable' -Subject 'fix: stable patch'
50+
Invoke-Git @('tag', 'v2026.5.3.0')
51+
52+
$stableBase = & $resolver -Tag 'v2026.5.3.0'
53+
if ($stableBase -ne 'v2026.5.1.0') {
54+
throw "Stable base was '$stableBase', expected 'v2026.5.1.0'."
55+
}
56+
57+
$preBase = & $resolver -Tag 'v2026.5.2.0-beta'
58+
if ($preBase -ne 'v2026.5.1.0') {
59+
throw "Prerelease base was '$preBase', expected 'v2026.5.1.0'."
60+
}
61+
62+
Write-Host 'Resolve-ReleaseBaseTag tests passed.'
63+
}
64+
finally {
65+
Pop-Location
66+
Remove-Item -LiteralPath $repo -Recurse -Force
67+
}

.github/workflows/release.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ jobs:
2828
# commits against the previous version tag for the changelog.
2929
fetch-depth: 0
3030

31+
- name: Test release base selection
32+
shell: pwsh
33+
run: ./.github/scripts/Test-ResolveReleaseBaseTag.ps1
34+
3135
- uses: actions/setup-go@v5
3236
with:
3337
go-version: '1.22'
@@ -101,9 +105,7 @@ jobs:
101105
# changelog grouped by type, extracted from `git log $prev..$tag`.
102106
# Bottom section is the static install snippet.
103107
104-
$prevTag = git tag --list 'v*' --sort=-version:refname |
105-
Where-Object { $_ -ne $env:TAG_NAME } |
106-
Select-Object -First 1
108+
$prevTag = & ./.github/scripts/Resolve-ReleaseBaseTag.ps1 -Tag $env:TAG_NAME
107109
108110
$sections = [ordered]@{
109111
feat = 'Features'

0 commit comments

Comments
 (0)