ci: publish a daily alpha from the newest fix commit (#106)
Alpha releases were rare because each one needed a manual tag. A scheduled workflow now runs at 00:00 Beijing time (16:00 UTC), picks the newest fix:/fix(scope):/fix!: commit on main, tags it vX.Y.Z-alpha.N and calls release.yml, so release tests, smoke and artifact checks still apply. It skips commits already in the latest stable tag or already released as an alpha, and retries the same tag when an earlier run pushed it but failed to publish. release.yml gains a workflow_call entry and reads the tag from env instead of interpolating it into the script. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
9f6b5de08c
commit
34b1569e59
6 files changed
+239
-3
No files matched your search
@@ -0,0 +1,67 @@
|
||||
name: Daily Alpha Release
|
||||
|
||||
# Every day at 00:00 Beijing time (16:00 UTC), build an alpha from the newest
|
||||
# `fix:` / `fix(scope):` commit on main. Nothing is built when that commit is
|
||||
# already in a stable release or already has a published alpha. GitHub may
|
||||
# start scheduled runs some minutes late under load.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 16 * * *"
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: "Only report which commit and tag would be used"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: alpha-release
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
outputs:
|
||||
build: ${{ steps.resolve.outputs.build }}
|
||||
tag: ${{ steps.resolve.outputs.tag }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: main
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Find newest fix commit and alpha tag
|
||||
id: resolve
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
shell: pwsh
|
||||
run: ./scripts/resolve-alpha-build.ps1 -Repo $env:GITHUB_REPOSITORY
|
||||
|
||||
- name: Push alpha tag
|
||||
if: steps.resolve.outputs.build == 'true' && steps.resolve.outputs.new_tag == 'true' && !inputs.dry_run
|
||||
env:
|
||||
TAG: ${{ steps.resolve.outputs.tag }}
|
||||
COMMIT: ${{ steps.resolve.outputs.commit }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
# Tags pushed with GITHUB_TOKEN do not trigger the tag-push release run,
|
||||
# so the release job below is the only build for this tag.
|
||||
git tag $env:TAG $env:COMMIT
|
||||
if ($LASTEXITCODE -ne 0) { throw "git tag $env:TAG failed ($LASTEXITCODE)" }
|
||||
git push origin "refs/tags/$env:TAG"
|
||||
if ($LASTEXITCODE -ne 0) { throw "git push refs/tags/$env:TAG failed ($LASTEXITCODE)" }
|
||||
|
||||
release:
|
||||
needs: plan
|
||||
if: needs.plan.outputs.build == 'true' && !inputs.dry_run
|
||||
permissions:
|
||||
contents: write
|
||||
uses: ./.github/workflows/release.yml
|
||||
with:
|
||||
tag: ${{ needs.plan.outputs.tag }}
|
||||
@@ -9,6 +9,12 @@ on:
|
||||
tag:
|
||||
description: "Release tag to build & publish (e.g. v0.2.9 or v0.2.9-alpha.1)"
|
||||
required: true
|
||||
workflow_call:
|
||||
inputs:
|
||||
tag:
|
||||
description: "Existing release tag to build & publish"
|
||||
required: true
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -22,7 +28,7 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
||||
ref: ${{ inputs.tag || '' }}
|
||||
fetch-depth: 0
|
||||
|
||||
- uses: actions/setup-go@v5
|
||||
@@ -40,10 +46,14 @@ jobs:
|
||||
cache-dependency-path: frontend/pnpm-lock.yaml
|
||||
|
||||
- name: Resolve version tag and channel
|
||||
env:
|
||||
# Set for manual runs and for calls from the daily alpha workflow; empty for tag pushes.
|
||||
INPUT_TAG: ${{ inputs.tag }}
|
||||
REF_NAME: ${{ github.ref_name }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') { '${{ inputs.tag }}' } else { '${{ github.ref_name }}' }
|
||||
$tag = if ($env:INPUT_TAG) { $env:INPUT_TAG } else { $env:REF_NAME }
|
||||
$tag = $tag.Trim()
|
||||
if ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+$') {
|
||||
$channel = 'stable'
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"group": "chores",
|
||||
"order": 1,
|
||||
"authors": ["Nwflower"],
|
||||
"zh": "每天北京时间 0 点以 `main` 上最新的 `fix` 提交自动发布 Alpha 测试版,该提交已发布时跳过。",
|
||||
"en": "Publish an alpha build every day at midnight Beijing time from the newest `fix` commit on `main`, skipping commits that were already released."
|
||||
}
|
||||
@@ -40,4 +40,8 @@
|
||||
3. 确定正式版版本及日期后,运行 `node scripts/changelog.mjs prepare vX.Y.Z --date YYYY-MM-DD`。命令将片段写入新版本,随后清理已写入的片段。清理中途失败时,可使用相同版本和日期重试。
|
||||
4. 审阅归档后的变更和片段删除,再按正常发布流程提交与打标签。[`scripts/build-release-notes.ps1`](../scripts/build-release-notes.ps1) 按标签抽取正文,加入下载与版本对比说明。Alpha 和滚动 Dev 使用提交摘要,待发布片段留到正式版统一编入。
|
||||
|
||||
## Alpha 测试版
|
||||
|
||||
每日 Alpha 流水线在北京时间每天 0 点运行,也可以在 Actions 页面手动运行或只预演。流水线取 `main` 上最新一个主题以 `fix:`、`fix(范围):` 或 `fix!:` 开头的提交,为它打上 `vX.Y.Z-alpha.N` 标签,并按版本标签发布流程构建和发布。`vX.Y.Z` 是下一个正式版号,`N` 在同一正式版号下递增。该提交已在最新正式版中,或已有对应 Alpha 发布时,当天不构建。上次标签已推送但发布失败时,流水线沿用原标签重试。正式版发布后会删除全部 Alpha 发布及其标签。
|
||||
|
||||
版本标题使用 `## vX.Y.Z — YYYY-MM-DD`,最新版本在前。每节提供中文及英文跳转,按固定分组记录本次变化。历史版本的勘误直接修正在对应版本。
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
| 核对发布候选 | `node scripts/test.mjs release` | 使用 `desktop,production` 构建标签运行同一套 Go 检查,禁用测试结果缓存并随机化用例顺序 |
|
||||
| Windows 桌面冒烟 | `node scripts/test.mjs webview2 build/bin/reims-go.exe` | 启动已构建的客户端,在真实 WebView2 中完成首启数据目录设置 |
|
||||
|
||||
GitHub CI 额外检查变更日志、工作区纪律、前端生产打包、Windows GUI 可执行文件的 `version` 输出与 WebView2 首启。`main` 的滚动版复用同一提交的 CI 测试,手动构建会跑 CI 测试并冒烟。带版本标签的发布先跑发布候选测试,再对待发布的 EXE 运行桌面冒烟。两个发布流程都在上传前验证实际 EXE 的版本、ZIP 内的文件和 SHA-256 校验和。
|
||||
GitHub CI 额外检查变更日志、工作区纪律、前端生产打包、Windows GUI 可执行文件的 `version` 输出与 WebView2 首启。`main` 的滚动版复用同一提交的 CI 测试,手动构建会跑 CI 测试并冒烟。带版本标签的发布与每日 Alpha 先跑发布候选测试,再对待发布的 EXE 运行桌面冒烟。两个发布流程都在上传前验证实际 EXE 的版本、ZIP 内的文件和 SHA-256 校验和。
|
||||
|
||||
桌面冒烟需要已安装 WebView2 Runtime 的 Windows 桌面会话。测试通过 Windows UI Automation 填入独立的数据目录、点击继续,检查配置和目录指针落盘,并等待运行时设置页渲染。每次运行使用独立的 WebView2 配置目录。失败时,测试入口打印保留的目录,应用日志在其中的 `app.log`。
|
||||
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
#Requires -Version 7.0
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Decide whether the daily alpha pipeline should build, and which tag to use.
|
||||
|
||||
.DESCRIPTION
|
||||
Finds the newest commit reachable from -Ref whose subject is a Conventional
|
||||
Commits fix (`fix: ...`, `fix(scope): ...`, `fix!: ...`), then:
|
||||
|
||||
- skips when there is no fix commit, or the commit is already part of the
|
||||
latest stable tag (vX.Y.Z);
|
||||
- reuses an existing vX.Y.Z-alpha[.N] tag on that commit, skipping when its
|
||||
GitHub Release already exists and rebuilding when an earlier run failed
|
||||
before publishing;
|
||||
- otherwise allocates the next vX.Y.Z-alpha.N, where vX.Y.Z is the next
|
||||
stable version (the patch after the latest stable tag, or the version in
|
||||
internal/version/version.go when that is higher).
|
||||
|
||||
The decision is printed and, under GitHub Actions, written to
|
||||
$GITHUB_OUTPUT as `build`, `tag`, `commit`, `new_tag`, and `reason`.
|
||||
The script does not create or push tags.
|
||||
#>
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Ref = 'HEAD',
|
||||
[string]$Repo = 'Nwflower/Reims-Go',
|
||||
[string]$VersionFile = 'internal/version/version.go'
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
|
||||
$fixSubject = '^fix(\([^)]*\))?!?:\s'
|
||||
$alphaTagPattern = '^v([0-9]+)\.([0-9]+)\.([0-9]+)-alpha(?:\.([0-9]+))?$'
|
||||
|
||||
function Invoke-Git {
|
||||
$out = @(& git @args)
|
||||
if ($LASTEXITCODE -ne 0) { throw "git $($args -join ' ') failed ($LASTEXITCODE)" }
|
||||
return $out
|
||||
}
|
||||
|
||||
function ConvertTo-StableVersion([string]$v) {
|
||||
if ($v -match '^v([0-9]+)\.([0-9]+)\.([0-9]+)$') {
|
||||
return [PSCustomObject]@{ Tag = $v; Major = [int]$Matches[1]; Minor = [int]$Matches[2]; Patch = [int]$Matches[3] }
|
||||
}
|
||||
return $null
|
||||
}
|
||||
|
||||
function Compare-StableVersion($a, $b) {
|
||||
if ($a.Major -ne $b.Major) { return [Math]::Sign($a.Major - $b.Major) }
|
||||
if ($a.Minor -ne $b.Minor) { return [Math]::Sign($a.Minor - $b.Minor) }
|
||||
return [Math]::Sign($a.Patch - $b.Patch)
|
||||
}
|
||||
|
||||
function Test-ReleaseExists([string]$tag) {
|
||||
$null = gh release view $tag -R $Repo --json tagName 2>$null
|
||||
return $LASTEXITCODE -eq 0
|
||||
}
|
||||
|
||||
function Write-Decision([bool]$build, [string]$tag, [string]$commit, [bool]$newTag, [string]$reason) {
|
||||
$decision = [ordered]@{
|
||||
build = $build.ToString().ToLowerInvariant()
|
||||
tag = $tag
|
||||
commit = $commit
|
||||
new_tag = $newTag.ToString().ToLowerInvariant()
|
||||
reason = $reason
|
||||
}
|
||||
foreach ($k in $decision.Keys) { Write-Host ("{0,-8} {1}" -f $k, $decision[$k]) }
|
||||
if ($env:GITHUB_OUTPUT) {
|
||||
$decision.GetEnumerator() | ForEach-Object { "$($_.Key)=$($_.Value)" } |
|
||||
Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
|
||||
}
|
||||
if ($env:GITHUB_STEP_SUMMARY) {
|
||||
$summary = if ($build) { "Alpha build: ``$tag`` from ``$commit`` ($reason)" } else { "No alpha build: $reason" }
|
||||
$summary | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Append -Encoding utf8
|
||||
}
|
||||
}
|
||||
|
||||
# 1. Newest fix commit. Merge commits are skipped; the fix commits they bring in are still visited.
|
||||
$fixCommit = ''
|
||||
$fixLine = ''
|
||||
foreach ($line in (Invoke-Git -c i18n.logOutputEncoding=utf-8 log $Ref --no-merges '--format=%H%x09%s')) {
|
||||
$sha, $subject = $line -split "`t", 2
|
||||
if ($subject -match $fixSubject) {
|
||||
$fixCommit = $sha
|
||||
$fixLine = $subject
|
||||
break
|
||||
}
|
||||
}
|
||||
if (-not $fixCommit) {
|
||||
Write-Decision $false '' '' $false "no fix commit reachable from $Ref"
|
||||
exit 0
|
||||
}
|
||||
$short = $fixCommit.Substring(0, 7)
|
||||
Write-Host "Newest fix commit: $short $fixLine"
|
||||
|
||||
# 2. Already shipped in a stable release?
|
||||
$stableTags = @(Invoke-Git tag --list 'v*' | ForEach-Object { ConvertTo-StableVersion $_.Trim() } | Where-Object { $_ } |
|
||||
Sort-Object Major, Minor, Patch -Descending)
|
||||
$latestStable = if ($stableTags.Count -gt 0) { $stableTags[0] } else { $null }
|
||||
if ($latestStable) {
|
||||
& git merge-base --is-ancestor $fixCommit $latestStable.Tag
|
||||
if ($LASTEXITCODE -eq 0) {
|
||||
Write-Decision $false '' $fixCommit $false "$short is already included in $($latestStable.Tag)"
|
||||
exit 0
|
||||
}
|
||||
if ($LASTEXITCODE -ne 1) { throw "git merge-base --is-ancestor failed ($LASTEXITCODE)" }
|
||||
}
|
||||
|
||||
# 3. Alpha tag already on this commit: skip if published, otherwise retry the same tag.
|
||||
$existing = @(Invoke-Git tag --points-at $fixCommit | ForEach-Object { $_.Trim() } | Where-Object { $_ -match $alphaTagPattern })
|
||||
if ($existing.Count -gt 0) {
|
||||
$tag = $existing | Sort-Object { [int]($_ -replace $alphaTagPattern, '$4' -replace '^$', '0') } -Descending | Select-Object -First 1
|
||||
if (Test-ReleaseExists $tag) {
|
||||
Write-Decision $false $tag $fixCommit $false "$short was already released as $tag"
|
||||
} else {
|
||||
Write-Decision $true $tag $fixCommit $false "$tag exists without a release; rebuilding"
|
||||
}
|
||||
exit 0
|
||||
}
|
||||
|
||||
# 4. Allocate the next alpha number for the upcoming stable version.
|
||||
$codeVer = $null
|
||||
if (Test-Path -LiteralPath $VersionFile) {
|
||||
$verText = Get-Content -Raw -LiteralPath $VersionFile
|
||||
if ($verText -match 'var\s+Version\s*=\s*"(v[0-9]+\.[0-9]+\.[0-9]+)"') {
|
||||
$codeVer = ConvertTo-StableVersion $Matches[1]
|
||||
}
|
||||
}
|
||||
if ($latestStable) {
|
||||
if ($codeVer -and (Compare-StableVersion $codeVer $latestStable) -gt 0) {
|
||||
$base = $codeVer.Tag
|
||||
} else {
|
||||
$base = "v$($latestStable.Major).$($latestStable.Minor).$($latestStable.Patch + 1)"
|
||||
}
|
||||
} elseif ($codeVer) {
|
||||
$base = $codeVer.Tag
|
||||
} else {
|
||||
$base = 'v0.0.1'
|
||||
}
|
||||
|
||||
$maxN = 0
|
||||
foreach ($t in (Invoke-Git tag --list "$base-alpha*")) {
|
||||
if ($t.Trim() -match $alphaTagPattern -and $Matches[4]) {
|
||||
$maxN = [Math]::Max($maxN, [int]$Matches[4])
|
||||
}
|
||||
}
|
||||
$tag = "$base-alpha.$($maxN + 1)"
|
||||
Write-Decision $true $tag $fixCommit $true "new alpha for $short"
|
||||
Reference in new issue
Block a user