A tag push occasionally fails to start this workflow, which leaves the release with no package. Dispatching with an existing tag rebuilds the same package from that tag instead of waiting for another push.
92 lines
3.6 KiB
YAML
92 lines
3.6 KiB
YAML
name: Release plugin package
|
|
|
|
on:
|
|
push:
|
|
tags: ['v*']
|
|
# A tag push can occasionally fail to start this workflow. Dispatching with
|
|
# an existing tag rebuilds the same package from that tag.
|
|
workflow_dispatch:
|
|
inputs:
|
|
tag:
|
|
description: 'Existing tag to package and release'
|
|
required: true
|
|
type: string
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
package:
|
|
runs-on: windows-latest
|
|
env:
|
|
RELEASE_TAG: ${{ inputs.tag || github.ref_name }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ env.RELEASE_TAG }}
|
|
- 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 = $env:RELEASE_TAG
|
|
$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 "$env:RELEASE_TAG" "${{ steps.package.outputs.zip_path }}" "${{ steps.package.outputs.sha_path }}" --verify-tag --generate-notes
|