* refactor: 收拢核心管线、强化错误处理、优化热路径与更新体积 * fix: preserve download recovery and bound PBZX decoding Keep VM diagnostics available during plugin initialization failures and verify settings through the unified driver lifecycle.
230 lines
8.8 KiB
YAML
230 lines
8.8 KiB
YAML
name: Dev Release (Rolling)
|
|
|
|
on:
|
|
workflow_call:
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
concurrency:
|
|
group: dev-release-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
GOCACHE: ${{ github.workspace }}/.debug/cache/go-build
|
|
|
|
jobs:
|
|
dev-release:
|
|
runs-on: windows-latest
|
|
timeout-minutes: 30
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- uses: pnpm/action-setup@v4
|
|
with:
|
|
version: 10
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 22
|
|
cache: pnpm
|
|
cache-dependency-path: frontend/pnpm-lock.yaml
|
|
|
|
- name: Resolve rolling dev version
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
function Parse-StableSemVer([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-SemVer($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)
|
|
}
|
|
|
|
$shortSha = (git rev-parse --short=7 HEAD).Trim()
|
|
if ([string]::IsNullOrWhiteSpace($shortSha)) {
|
|
throw 'Could not resolve HEAD short commit SHA'
|
|
}
|
|
|
|
$stableTags = @(
|
|
git tag --list 'v*' |
|
|
ForEach-Object { Parse-StableSemVer $_.Trim() } |
|
|
Where-Object { $_ -ne $null } |
|
|
Sort-Object Major, Minor, Patch -Descending
|
|
)
|
|
$latestStable = if ($stableTags.Count -gt 0) { $stableTags[0] } else { $null }
|
|
|
|
$codeVer = $null
|
|
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
|
if ($verFile -match 'var\s+Version\s*=\s*"(v[0-9]+\.[0-9]+\.[0-9]+)"') {
|
|
$codeVer = Parse-StableSemVer $Matches[1]
|
|
}
|
|
|
|
if ($latestStable) {
|
|
if ($codeVer -and (Compare-SemVer $codeVer $latestStable) -gt 0) {
|
|
$nextBase = $codeVer.Tag
|
|
} else {
|
|
$nextBase = "v$($latestStable.Major).$($latestStable.Minor).$($latestStable.Patch + 1)"
|
|
}
|
|
$baseStableTag = $latestStable.Tag
|
|
} elseif ($codeVer) {
|
|
$nextBase = $codeVer.Tag
|
|
$baseStableTag = ''
|
|
} else {
|
|
$nextBase = 'v0.0.1'
|
|
$baseStableTag = ''
|
|
}
|
|
|
|
$devVersion = "$nextBase-dev-$shortSha"
|
|
"DEV_VERSION=$devVersion" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
"DEV_COMMIT=$shortSha" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
"BASE_STABLE_TAG=$baseStableTag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
Write-Host "Resolved DEV_VERSION=$devVersion (commit=$shortSha, baseStable=$baseStableTag)"
|
|
|
|
- name: Generate dev release notes
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$devVersion = $env:DEV_VERSION
|
|
New-Item -ItemType Directory -Force -Path .debug/runs/dev-release | Out-Null
|
|
$notesFile = Join-Path $PWD '.debug/runs/dev-release/release-notes-dev.md'
|
|
& ./scripts/build-release-notes.ps1 `
|
|
-Tag $devVersion `
|
|
-Channel dev `
|
|
-PrevTag $env:BASE_STABLE_TAG `
|
|
-Commit $env:DEV_COMMIT `
|
|
-Repo $env:GITHUB_REPOSITORY `
|
|
-DiscoverStableRuntime `
|
|
-OutFile $notesFile
|
|
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
Write-Host "Generated dev release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $devVersion"
|
|
|
|
- name: Install frontend dependencies
|
|
shell: pwsh
|
|
run: pnpm --dir frontend install --frozen-lockfile
|
|
|
|
- name: CI tests for manual builds
|
|
if: github.event_name == 'workflow_dispatch'
|
|
shell: pwsh
|
|
run: node scripts/test.mjs ci
|
|
|
|
- name: Bundle frontend
|
|
shell: pwsh
|
|
run: pnpm --dir frontend bundle
|
|
|
|
- name: Install Wails CLI
|
|
shell: pwsh
|
|
run: go install github.com/wailsapp/wails/v2/cmd/wails@v2.17.1
|
|
|
|
- name: Build Windows x64 binary
|
|
shell: pwsh
|
|
env:
|
|
CGO_ENABLED: "0"
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$ver = $env:DEV_VERSION
|
|
$dist = 'dist-release'
|
|
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
|
$verPkg = 'github.com/Nwflower/reims-go/internal/version'
|
|
$guiOut = Join-Path $dist "reims-go-$ver-windows-amd64.exe"
|
|
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$ver" -o "reims-go-$ver-windows-amd64.exe"
|
|
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
|
Copy-Item (Join-Path 'build\bin' "reims-go-$ver-windows-amd64.exe") $guiOut
|
|
$zipOut = [IO.Path]::ChangeExtension($guiOut, '.zip')
|
|
Compress-Archive -LiteralPath @($guiOut, 'LICENSE', 'NOTICE.md') -DestinationPath $zipOut -CompressionLevel Optimal -Force
|
|
$lines = @(Get-Item -LiteralPath $guiOut, $zipOut | ForEach-Object {
|
|
$h = (Get-FileHash -Algorithm SHA256 -LiteralPath $_.FullName).Hash.ToLowerInvariant()
|
|
"$h $($_.Name)"
|
|
})
|
|
[IO.File]::WriteAllText((Join-Path $dist 'SHA256SUMS.txt'), ($lines -join "`n") + "`n", [Text.UTF8Encoding]::new($false))
|
|
Get-Content (Join-Path $dist 'SHA256SUMS.txt')
|
|
|
|
- name: Verify release artifacts
|
|
shell: pwsh
|
|
run: ./scripts/check-release-artifact.ps1 -Executable "dist-release/reims-go-$env:DEV_VERSION-windows-amd64.exe" -Version $env:DEV_VERSION -Package
|
|
|
|
- name: WebView2 first-launch smoke for manual builds
|
|
if: github.event_name == 'workflow_dispatch'
|
|
timeout-minutes: 3
|
|
run: node scripts/test.mjs webview2 "dist-release/reims-go-$env:DEV_VERSION-windows-amd64.exe"
|
|
|
|
- name: Update rolling dev GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$releaseTag = 'dev'
|
|
$ver = $env:DEV_VERSION
|
|
$notesFile = $env:RELEASE_NOTES_FILE
|
|
if (-not (Test-Path -LiteralPath $notesFile) -or (Get-Item -LiteralPath $notesFile).Length -eq 0) {
|
|
throw "Release notes file is missing or empty: $notesFile"
|
|
}
|
|
$title = "Reims-Go Dev ($ver)"
|
|
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
|
$keepNames = @($files | ForEach-Object { [IO.Path]::GetFileName($_) })
|
|
|
|
# Point the fixed 'dev' tag to the commit being built.
|
|
git tag -f $releaseTag $env:GITHUB_SHA
|
|
if ($LASTEXITCODE -ne 0) { throw "git tag -f $releaseTag failed ($LASTEXITCODE)" }
|
|
git push --force origin "refs/tags/$releaseTag"
|
|
if ($LASTEXITCODE -ne 0) { throw "git push --force refs/tags/$releaseTag failed ($LASTEXITCODE)" }
|
|
|
|
$exists = $true
|
|
$existingAssets = @()
|
|
try {
|
|
$relJson = gh release view $releaseTag --json assets 2>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
$exists = $false
|
|
} else {
|
|
$existingAssets = @(($relJson | ConvertFrom-Json).assets)
|
|
}
|
|
} catch {
|
|
$exists = $false
|
|
}
|
|
|
|
if ($exists) {
|
|
# Upload new assets first so the release is never left empty if upload fails.
|
|
gh release upload $releaseTag @files --clobber
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
|
foreach ($asset in $existingAssets) {
|
|
if ($keepNames -notcontains $asset.name) {
|
|
Write-Host "Removing stale dev asset $($asset.name)"
|
|
gh release delete-asset $releaseTag $asset.name --yes
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release delete-asset $($asset.name) failed ($LASTEXITCODE)" }
|
|
}
|
|
}
|
|
gh release edit $releaseTag `
|
|
--target $env:GITHUB_SHA `
|
|
--prerelease `
|
|
--title $title `
|
|
--notes-file $notesFile
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
|
} else {
|
|
gh release create $releaseTag @files `
|
|
--target $env:GITHUB_SHA `
|
|
--prerelease `
|
|
--title $title `
|
|
--notes-file $notesFile
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
|
}
|