133 lines
4.8 KiB
YAML
133 lines
4.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- 'README.md'
|
|
- 'README.*.md'
|
|
- 'AGENTS.md'
|
|
- '.github/ISSUE_TEMPLATE/**'
|
|
- '.github/PULL_REQUEST_TEMPLATE.md'
|
|
- '.github/readme/**'
|
|
pull_request:
|
|
branches: [main]
|
|
paths-ignore:
|
|
- 'docs/**'
|
|
- 'README.md'
|
|
- 'README.*.md'
|
|
- 'AGENTS.md'
|
|
- '.github/ISSUE_TEMPLATE/**'
|
|
- '.github/PULL_REQUEST_TEMPLATE.md'
|
|
- '.github/readme/**'
|
|
|
|
concurrency:
|
|
group: ci-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
GOCACHE: ${{ github.workspace }}/.debug/cache/go-build
|
|
|
|
jobs:
|
|
verify:
|
|
runs-on: windows-latest
|
|
timeout-minutes: 30
|
|
outputs:
|
|
rolling: ${{ steps.rolling.outputs.publish }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Check whether this push affects the rolling release
|
|
id: rolling
|
|
if: github.event_name == 'push'
|
|
env:
|
|
PREVIOUS_SHA: ${{ github.event.before }}
|
|
shell: pwsh
|
|
run: |
|
|
# Read the commit object so shallow checkouts retain its parent headers.
|
|
$commitLines = @(git cat-file commit HEAD)
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not read the main commit' }
|
|
$headerEnd = [Array]::IndexOf($commitLines, '')
|
|
if ($headerEnd -lt 1) { throw 'Could not locate the main commit message' }
|
|
$parents = @($commitLines[0..($headerEnd - 1)] -like 'parent *')
|
|
$subject = $commitLines[$headerEnd + 1]
|
|
$publish = $parents.Count -le 1 -and $subject -like '*#*' -and $subject -notlike '*docs*'
|
|
if ($publish -and $env:PREVIOUS_SHA -notmatch '^0+$') {
|
|
git fetch --depth=1 origin $env:PREVIOUS_SHA
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not fetch the previous main commit' }
|
|
$changed = git diff --name-only $env:PREVIOUS_SHA HEAD -- . ':(exclude)docs/**' ':(exclude)README.md' ':(exclude,glob)README.*.md' ':(exclude)AGENTS.md' ':(exclude).github/ISSUE_TEMPLATE/**' ':(exclude).github/PULL_REQUEST_TEMPLATE.md' ':(exclude).github/readme/**'
|
|
if ($LASTEXITCODE -ne 0) { throw 'Could not compare the pushed commits' }
|
|
$publish = [bool]$changed
|
|
}
|
|
"publish=$($publish.ToString().ToLowerInvariant())" >> $env:GITHUB_OUTPUT
|
|
|
|
- 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: Verify CHANGELOG.md matches current version
|
|
shell: pwsh
|
|
run: |
|
|
$ErrorActionPreference = 'Stop'
|
|
node scripts/changelog.mjs check
|
|
if ($LASTEXITCODE -ne 0) { throw 'Changelog validation failed' }
|
|
$verFile = Get-Content -Raw -LiteralPath 'internal/version/version.go'
|
|
if ($verFile -notmatch 'var\s+Version\s*=\s*"(v[^"]+)"') {
|
|
throw 'Could not parse Version from internal/version/version.go'
|
|
}
|
|
$ver = $Matches[1]
|
|
New-Item -ItemType Directory -Force -Path .debug/runs/ci | Out-Null
|
|
$tmp = Join-Path $PWD ".debug/runs/ci/release-notes-$ver.md"
|
|
& ./scripts/build-release-notes.ps1 -Tag $ver -OutFile $tmp
|
|
"REIMS_APP_VERSION=$ver" >> $env:GITHUB_ENV
|
|
Write-Host "PASS CHANGELOG.md contains valid release notes for $ver ($((Get-Item -LiteralPath $tmp).Length) bytes)"
|
|
|
|
- name: Workspace hygiene
|
|
shell: pwsh
|
|
run: node scripts/debug/check.mjs
|
|
|
|
- name: Install frontend dependencies
|
|
shell: pwsh
|
|
run: pnpm --dir frontend install --frozen-lockfile
|
|
|
|
- name: CI tests
|
|
shell: pwsh
|
|
run: node scripts/test.mjs ci
|
|
|
|
- name: Bundle frontend
|
|
shell: pwsh
|
|
run: pnpm --dir frontend bundle
|
|
|
|
- name: Build reims-go.exe (window + command-line mode)
|
|
shell: pwsh
|
|
run: |
|
|
$env:GOTMPDIR = (Resolve-Path .debug/runs/ci).Path
|
|
$exe = '.debug/runs/ci/reims-go.exe'
|
|
go vet -tags desktop,production .
|
|
if ($LASTEXITCODE -ne 0) { throw 'Go desktop vet failed' }
|
|
go build -trimpath -tags desktop,production -ldflags "-H windowsgui" -o $exe .
|
|
if ($LASTEXITCODE -ne 0) { throw 'Go desktop build failed' }
|
|
./scripts/check-release-artifact.ps1 -Executable $exe -Version $env:REIMS_APP_VERSION
|
|
|
|
- name: WebView2 first-launch smoke
|
|
timeout-minutes: 3
|
|
run: node scripts/test.mjs webview2 .debug/runs/ci/reims-go.exe
|
|
|
|
rolling-release:
|
|
needs: verify
|
|
if: needs.verify.outputs.rolling == 'true'
|
|
permissions:
|
|
contents: write
|
|
uses: ./.github/workflows/dev-release.yml
|