Resolve merge conflicts with main in frontend/src/i18n.ts and internal/i18n/i18n.go, migrate the 12 i18n keys added on main since branching (CoW backing chain diagnostics and About open-source license viewer) into locales/{zh-CN,en-US}/*.json, and regenerate catalogs via cmd/i18ngen.
207 lines
8.3 KiB
YAML
207 lines
8.3 KiB
YAML
name: Release Reims-Go
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: "Release tag to build & publish (e.g. v0.2.9 or v0.2.9-alpha.1)"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || '' }}
|
|
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 version tag and channel
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') { '${{ inputs.tag }}' } else { '${{ github.ref_name }}' }
|
|
$tag = $tag.Trim()
|
|
if ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+$') {
|
|
$channel = 'stable'
|
|
} elseif ($tag -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$') {
|
|
$channel = 'alpha'
|
|
} else {
|
|
throw "Release tag must be stable (vX.Y.Z) or alpha test (vX.Y.Z-alpha[.N]), got: $tag"
|
|
}
|
|
"RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
"RELEASE_CHANNEL=$channel" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
Write-Host "Resolved tag=$tag channel=$channel"
|
|
|
|
- name: Generate release notes
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$tag = $env:RELEASE_TAG
|
|
$channel = $env:RELEASE_CHANNEL
|
|
$runtimeTag = ''
|
|
$runtimeTitle = ''
|
|
try {
|
|
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 100 --json tagName,name,isPrerelease,isDraft,createdAt | ConvertFrom-Json
|
|
$stable = $rels |
|
|
Where-Object { $_.tagName -like 'runtime-*' -and -not $_.isPrerelease -and -not $_.isDraft } |
|
|
Sort-Object createdAt -Descending |
|
|
Select-Object -First 1
|
|
if ($stable) {
|
|
$runtimeTag = $stable.tagName
|
|
$runtimeTitle = if ($stable.name) { $stable.name } else { $stable.tagName }
|
|
}
|
|
} catch {
|
|
Write-Warning "Could not query latest stable runtime release: $_"
|
|
}
|
|
$notesFile = Join-Path $env:RUNNER_TEMP "release-notes-$tag.md"
|
|
& ./scripts/build-release-notes.ps1 `
|
|
-Tag $tag `
|
|
-Channel $channel `
|
|
-ChangelogPath 'CHANGELOG.md' `
|
|
-Repo $env:GITHUB_REPOSITORY `
|
|
-StableRuntimeTag $runtimeTag `
|
|
-StableRuntimeTitle $runtimeTitle `
|
|
-OutFile $notesFile
|
|
"RELEASE_NOTES_FILE=$notesFile" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
Write-Host "Generated $channel release notes ($((Get-Item -LiteralPath $notesFile).Length) bytes) for $tag"
|
|
|
|
- name: Build frontend
|
|
shell: pwsh
|
|
run: |
|
|
pnpm --dir frontend install --frozen-lockfile
|
|
pnpm --dir frontend build
|
|
|
|
- name: Go test & vet
|
|
shell: pwsh
|
|
run: |
|
|
go test ./...
|
|
go vet ./...
|
|
|
|
- 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
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$tag = $env:RELEASE_TAG
|
|
$dist = 'dist-release'
|
|
New-Item -ItemType Directory -Force -Path $dist | Out-Null
|
|
$verPkg = 'github.com/Nwflower/reims-go/internal/version'
|
|
# One executable: the window without arguments, command-line mode with a command.
|
|
$guiOut = Join-Path $dist "reims-go-$tag-windows-amd64.exe"
|
|
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$tag" -o "reims-go-$tag-windows-amd64.exe"
|
|
if ($LASTEXITCODE) { throw "wails build failed ($LASTEXITCODE)" }
|
|
Copy-Item (Join-Path 'build\bin' "reims-go-$tag-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: Publish GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
$tag = $env:RELEASE_TAG
|
|
$channel = $env:RELEASE_CHANNEL
|
|
$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 = if ($channel -eq 'alpha') { "Reims-Go $tag (Alpha)" } else { "Reims-Go $tag" }
|
|
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
|
$exists = $true
|
|
$existingBody = ''
|
|
try {
|
|
$relJson = gh release view $tag --json body 2>$null
|
|
if ($LASTEXITCODE -ne 0) {
|
|
$exists = $false
|
|
} else {
|
|
$existingBody = (($relJson | ConvertFrom-Json).body | Out-String).Trim()
|
|
}
|
|
} catch {
|
|
$exists = $false
|
|
}
|
|
if ($exists) {
|
|
gh release upload $tag @files --clobber
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release upload failed ($LASTEXITCODE)" }
|
|
$editArgs = @('release', 'edit', $tag, '--title', $title)
|
|
if ($channel -eq 'alpha') {
|
|
$editArgs += '--prerelease'
|
|
} else {
|
|
$editArgs += @('--prerelease=false', '--latest')
|
|
}
|
|
# Backfill notes if the existing release body is empty or only GitHub's auto-generated compare link.
|
|
$isAutoOnly = [string]::IsNullOrWhiteSpace($existingBody) -or ($existingBody -match '^\*\*Full Changelog\*\*:\s*https://\S+$')
|
|
if ($isAutoOnly) {
|
|
$editArgs += @('--notes-file', $notesFile)
|
|
}
|
|
& gh @editArgs
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release edit failed ($LASTEXITCODE)" }
|
|
} else {
|
|
$createArgs = @('release', 'create', $tag) + $files + @('--title', $title, '--notes-file', $notesFile)
|
|
if ($channel -eq 'alpha') {
|
|
$createArgs += '--prerelease'
|
|
} else {
|
|
$createArgs += '--latest'
|
|
}
|
|
& gh @createArgs
|
|
if ($LASTEXITCODE -ne 0) { throw "gh release create failed ($LASTEXITCODE)" }
|
|
}
|
|
|
|
- name: Delete all published alpha test releases after stable release
|
|
if: env.RELEASE_CHANNEL == 'stable'
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
# Only delete app alpha prereleases (vX.Y.Z-alpha*); never touch runtime-* or the rolling dev release.
|
|
$rels = gh release list -R $env:GITHUB_REPOSITORY --limit 1000 --json tagName,isPrerelease,isDraft | ConvertFrom-Json
|
|
$alphas = @($rels | Where-Object {
|
|
$_.isPrerelease -and
|
|
-not $_.isDraft -and
|
|
$_.tagName -match '^v[0-9]+\.[0-9]+\.[0-9]+-alpha(?:[.-][0-9A-Za-z.-]+)?$'
|
|
})
|
|
if ($alphas.Count -eq 0) {
|
|
Write-Host "No published alpha test releases to clean up."
|
|
exit 0
|
|
}
|
|
foreach ($rel in $alphas) {
|
|
Write-Host "Deleting alpha test release $($rel.tagName)"
|
|
gh release delete $rel.tagName -R $env:GITHUB_REPOSITORY --yes --cleanup-tag
|
|
if ($LASTEXITCODE -ne 0) {
|
|
throw "Failed to delete alpha test release $($rel.tagName) (exit $LASTEXITCODE)"
|
|
}
|
|
}
|