101 lines
3.3 KiB
YAML
101 lines
3.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.1)"
|
|
required: true
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- 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
|
|
shell: pwsh
|
|
run: |
|
|
$tag = if ('${{ github.event_name }}' -eq 'workflow_dispatch') { '${{ inputs.tag }}' } else { '${{ github.ref_name }}' }
|
|
if (-not $tag.StartsWith('v')) { throw "Release tag must start with 'v', got: $tag" }
|
|
"RELEASE_TAG=$tag" | Out-File -FilePath $env:GITHUB_ENV -Append
|
|
|
|
- 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 GUI & CLI binaries
|
|
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'
|
|
$guiOut = Join-Path $dist "reims-go-$tag-windows-amd64.exe"
|
|
$cliOut = Join-Path $dist "reims-go-cli-$tag-windows-amd64.exe"
|
|
wails build -s -trimpath -ldflags "-s -w -X $verPkg.Version=$tag" -o "reims-go-$tag-windows-amd64.exe"
|
|
Copy-Item (Join-Path 'build\bin' "reims-go-$tag-windows-amd64.exe") $guiOut
|
|
go build -trimpath -ldflags "-s -w -X $verPkg.Version=$tag" -o $cliOut ./cmd/reims-go
|
|
$lines = @(Get-ChildItem -LiteralPath $dist -File | Sort-Object Name | 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
|
|
$files = @(Get-ChildItem -LiteralPath 'dist-release' -File | Select-Object -ExpandProperty FullName)
|
|
$exists = $true
|
|
try {
|
|
gh release view $tag *> $null
|
|
if ($LASTEXITCODE -ne 0) { $exists = $false }
|
|
} catch {
|
|
$exists = $false
|
|
}
|
|
if ($exists) {
|
|
gh release upload $tag @files --clobber
|
|
} else {
|
|
gh release create $tag @files `
|
|
--title "Reims-Go $tag" `
|
|
--generate-notes
|
|
}
|