Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cmd/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions cmd/plugin/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
}
Expand Down Expand Up @@ -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())
}
}
Expand Down
96 changes: 96 additions & 0 deletions schema/v1.json
Original file line number Diff line number Diff line change
@@ -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
}
Loading