From b5a87a685a7842c207cc6a19220f3acbdf6337ab Mon Sep 17 00:00:00 2001 From: Markus Waldheim Date: Wed, 10 Jun 2026 11:03:29 +0200 Subject: [PATCH] feat: add schema versioning support Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- cmd/plugin/main.go | 3 ++ cmd/plugin/main_test.go | 4 +- schema/v1.json | 96 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 schema/v1.json diff --git a/cmd/plugin/main.go b/cmd/plugin/main.go index efe03ce..65c969e 100644 --- a/cmd/plugin/main.go +++ b/cmd/plugin/main.go @@ -13,6 +13,8 @@ import ( plugin "github.com/SemRels/provider-github/internal/plugin" ) +const pluginSchemaVersion = 1 + func run( ctx context.Context, getenv func(string) string, @@ -21,6 +23,7 @@ func run( createRelease func(context.Context, plugin.Config) (*plugin.Release, error), uploadAssets func(context.Context, plugin.Config, *plugin.Release, io.Writer), ) int { + fmt.Fprintf(stderr, "plugin_schema_version=%d\n", pluginSchemaVersion) cfg, err := plugin.ConfigFromEnv(getenv) if err != nil { fmt.Fprintln(stderr, "provider-github:", err) diff --git a/cmd/plugin/main_test.go b/cmd/plugin/main_test.go index 92fd4c6..c3b3d62 100644 --- a/cmd/plugin/main_test.go +++ b/cmd/plugin/main_test.go @@ -38,7 +38,7 @@ func TestRunSuccess(t *testing.T) { if !uploadCalled { t.Fatal("expected uploadAssets to be called") } - if stderr.Len() != 0 || !strings.Contains(stdout.String(), "created v1.2.3") { + if stderr.String() != "plugin_schema_version=1\n" || !strings.Contains(stdout.String(), "created v1.2.3") { t.Fatalf("stdout=%q stderr=%q", stdout.String(), stderr.String()) } } @@ -68,7 +68,7 @@ func TestRunDryRun(t *testing.T) { if uploadCalled { t.Fatal("uploadAssets should not be called during dry-run") } - if stderr.Len() != 0 || !strings.Contains(stdout.String(), "dry-run") { + if stderr.String() != "plugin_schema_version=1\n" || !strings.Contains(stdout.String(), "dry-run") { t.Fatalf("stdout=%q stderr=%q", stdout.String(), stderr.String()) } } diff --git a/schema/v1.json b/schema/v1.json new file mode 100644 index 0000000..8f96ad5 --- /dev/null +++ b/schema/v1.json @@ -0,0 +1,96 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "$id": "https://registry.semrel.io/schemas/plugins/provider-github/v1.json", + "title": "provider-github plugin configuration", + "description": "Schema v1 for the provider-github semrel plugin. Configure via SEMREL_* environment variables.", + "type": "object", + "properties": { + "SEMREL_PLUGIN_TOKEN": { + "type": "string", + "description": "GitHub token used to create the release. In practice this is often sourced from GITHUB_TOKEN.", + "writeOnly": true + }, + "SEMREL_PLUGIN_OWNER": { + "type": "string", + "description": "GitHub repository owner or organization." + }, + "SEMREL_PLUGIN_REPO": { + "type": "string", + "description": "GitHub repository name." + }, + "SEMREL_PLUGIN_BASE_URL": { + "type": "string", + "default": "https://github.com", + "description": "GitHub web base URL.", + "format": "uri" + }, + "SEMREL_PLUGIN_API_URL": { + "type": "string", + "default": "https://api.github.com", + "description": "GitHub API base URL.", + "format": "uri" + }, + "SEMREL_PLUGIN_DRAFT": { + "type": "string", + "enum": [ + "true", + "false", + "1", + "0" + ], + "default": "false", + "description": "Create the release as a draft." + }, + "SEMREL_PLUGIN_PRERELEASE": { + "type": "string", + "enum": [ + "true", + "false", + "1", + "0" + ], + "default": "false", + "description": "Mark the release as a prerelease." + }, + "SEMREL_PLUGIN_NAME": { + "type": "string", + "description": "Optional release name override." + }, + "SEMREL_PLUGIN_TAG_NAME": { + "type": "string", + "description": "Optional tag name override." + }, + "SEMREL_PLUGIN_ASSETS": { + "type": "string", + "description": "Optional comma-separated file globs for release assets to upload." + }, + "SEMREL_TAG_NAME": { + "type": "string", + "description": "Release tag name for the current semrel execution." + }, + "SEMREL_VERSION": { + "type": "string", + "description": "Release version for the current semrel execution. semrel core may expose this as SEMREL_VERSION, SEMREL_TAG_NAME, or SEMREL_NEXT_VERSION depending on phase." + }, + "SEMREL_NEXT_VERSION": { + "type": "string", + "description": "Calculated next release version when SEMREL_VERSION is not yet finalized." + }, + "SEMREL_CHANGELOG": { + "type": "string", + "description": "Generated release notes or changelog content from semrel core." + }, + "SEMREL_DRY_RUN": { + "type": "string", + "enum": [ + "true", + "false", + "1", + "0" + ], + "default": "false", + "description": "When true, perform validation and logging only without executing side effects." + } + }, + "additionalProperties": true +}