80 lines
3.2 KiB
YAML
80 lines
3.2 KiB
YAML
name: Release plugin package
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
package:
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version-file: go.mod
|
|
cache-dependency-path: go.sum
|
|
- name: Test and build Windows sidecar
|
|
shell: pwsh
|
|
run: |
|
|
go test ./...
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
go vet ./...
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
New-Item -ItemType Directory -Force -Path bin | Out-Null
|
|
$env:GOOS = 'windows'
|
|
$env:GOARCH = 'amd64'
|
|
$env:CGO_ENABLED = '0'
|
|
go build -trimpath -o bin/reims-agent.exe ./cmd/reims-agent
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
- name: Build headless Reims-Go plugin CLI outside workspace
|
|
shell: pwsh
|
|
run: |
|
|
$cliRepo = Join-Path $env:RUNNER_TEMP 'reims-go'
|
|
git clone --depth 1 --branch main https://github.com/Nwflower/Reims-Go.git $cliRepo
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
$doctorDir = Join-Path $cliRepo 'cmd/reims-doctor'
|
|
New-Item -ItemType Directory -Force -Path $doctorDir | Out-Null
|
|
@'
|
|
package main
|
|
|
|
import (
|
|
"os"
|
|
"github.com/Nwflower/reims-go/internal/cli"
|
|
)
|
|
|
|
func main() { os.Exit(cli.Main(os.Args[1:])) }
|
|
'@ | Set-Content -Encoding utf8 (Join-Path $doctorDir 'main.go')
|
|
$cliBin = Join-Path $env:RUNNER_TEMP 'reims-go-plugin-cli.exe'
|
|
$env:CGO_ENABLED = '0'
|
|
go build -C $cliRepo -trimpath -o $cliBin ./cmd/reims-doctor
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
- name: Validate and package plugin
|
|
id: package
|
|
shell: pwsh
|
|
run: |
|
|
$tag = '${{ github.ref_name }}'
|
|
$version = $tag.Substring(1)
|
|
$manifest = Get-Content -Raw plugin.json | ConvertFrom-Json
|
|
if ($manifest.version -ne $version) { throw "Tag $tag does not match plugin.json version $($manifest.version)" }
|
|
$cliBin = Join-Path $env:RUNNER_TEMP 'reims-go-plugin-cli.exe'
|
|
$zipPath = Join-Path $env:RUNNER_TEMP "reims.agent-$version.zip"
|
|
$shaPath = Join-Path $env:RUNNER_TEMP "reims.agent-$version.sha256"
|
|
& $cliBin plugin doctor .
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
& $cliBin plugin pack --out $zipPath .
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
$hash = (Get-FileHash $zipPath -Algorithm SHA256).Hash.ToLowerInvariant()
|
|
"$hash reims.agent-$version.zip" | Set-Content -Encoding ascii $shaPath
|
|
"version=$version" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
"zip_path=$zipPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
"sha_path=$shaPath" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
|
|
- name: Publish GitHub Release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
shell: pwsh
|
|
run: |
|
|
gh release create "${{ github.ref_name }}" "${{ steps.package.outputs.zip_path }}" "${{ steps.package.outputs.sha_path }}" --verify-tag --generate-notes
|