Skip to content

Commit d83fa8d

Browse files
intel352claude
andcommitted
refactor: inject plugin version at build time via ldflags
Replace hardcoded Version string in Manifest() with a package-level var that goreleaser populates via -ldflags -X. This ensures the plugin's reported Manifest().Version matches the release tag, so the workflow engine's requires.plugins[].version check passes. Also add sed before-hook to bump plugin.json at release time. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 22aa940 commit d83fa8d

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

.goreleaser.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ project_name: workflow-plugin-github
55
before:
66
hooks:
77
- go mod tidy
8+
- "sed -i.bak 's/\"version\": \".*\"/\"version\": \"{{ .Version }}\"/' plugin.json && rm -f plugin.json.bak"
89

910
builds:
1011
- id: workflow-plugin-github
@@ -20,6 +21,8 @@ builds:
2021
goarch:
2122
- amd64
2223
- arm64
24+
ldflags:
25+
- -s -w -X github.com/GoCodeAlone/workflow-plugin-github/internal.Version={{.Version}}
2326

2427
archives:
2528
- id: workflow-plugin-github

internal/plugin.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import (
66
sdk "github.com/GoCodeAlone/workflow/plugin/external/sdk"
77
)
88

9+
// Version is set at build time via -ldflags
10+
// "-X github.com/GoCodeAlone/workflow-plugin-github/internal.Version=X.Y.Z"
11+
var Version = "dev"
12+
913
// webhookRouteConfig is the config fragment YAML that declares the GitHub
1014
// webhook HTTP route so the engine's HTTP server registers it via the normal
1115
// config pipeline instead of the unreachable global DefaultServeMux.
@@ -32,7 +36,7 @@ func NewGitHubPlugin() sdk.PluginProvider {
3236
func (p *githubPlugin) Manifest() sdk.PluginManifest {
3337
return sdk.PluginManifest{
3438
Name: "workflow-plugin-github",
35-
Version: "1.0.1",
39+
Version: Version,
3640
Author: "GoCodeAlone",
3741
Description: "GitHub integration plugin: webhook handling, GitHub Actions, PRs, issues, releases, and deployments",
3842
}

0 commit comments

Comments
 (0)