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 @@ -11,6 +11,8 @@ import (
plugin "github.com/SemRels/hook-gitplugin/internal/plugin"
)

const pluginSchemaVersion = 1

type gitPlugin interface {
Validate() error
CommitFiles(context.Context, string, string) error
Expand All @@ -24,6 +26,7 @@ var (
)

func run(ctx context.Context, getenv func(string) string, stderr io.Writer) int {
fmt.Fprintf(stderr, "plugin_schema_version=%d\n", pluginSchemaVersion)
tagName := firstNonEmpty(getenv("SEMREL_PLUGIN_TAG_NAME"), getenv("SEMREL_TAG_NAME"), getenv("SEMREL_VERSION"), getenv("SEMREL_NEXT_VERSION"))
versionSource := firstNonEmpty(getenv("SEMREL_VERSION"), getenv("SEMREL_TAG_NAME"), getenv("SEMREL_NEXT_VERSION"), tagName)
if tagName == "" || versionSource == "" {
Expand Down
2 changes: 1 addition & 1 deletion cmd/plugin/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func TestRunSuccess(t *testing.T) {
"SEMREL_PLUGIN_SIGN_TAG": "true",
"SEMREL_PLUGIN_SIGNED_OFF_BY": "true",
}), &stderr)
if code != 0 || stderr.Len() != 0 {
if code != 0 || stderr.String() != "plugin_schema_version=1\n" {
t.Fatalf("unexpected result: code=%d stderr=%q", code, stderr.String())
}
if got := len(fake.calls); got != 3 {
Expand Down
88 changes: 88 additions & 0 deletions schema/v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://registry.semrel.io/schemas/plugins/hook-gitplugin/v1.json",
"title": "hook-gitplugin plugin configuration",
"description": "Schema v1 for the hook-gitplugin semrel plugin. Configure via SEMREL_* environment variables.",
"type": "object",
"properties": {
"SEMREL_PLUGIN_FILES": {
"type": "string",
"description": "Comma-, semicolon-, or newline-separated file paths to include in the release commit."
},
"SEMREL_PLUGIN_COMMIT_MESSAGE": {
"type": "string",
"description": "Optional commit message override for the release commit."
},
"SEMREL_PLUGIN_BRANCH": {
"type": "string",
"description": "Optional branch override. Falls back to SEMREL_BRANCH."
},
"SEMREL_PLUGIN_REMOTE": {
"type": "string",
"default": "origin",
"description": "Git remote to push to."
},
"SEMREL_PLUGIN_TAG_NAME": {
"type": "string",
"description": "Optional tag name override. Falls back to SEMREL_TAG_NAME / SEMREL_VERSION / SEMREL_NEXT_VERSION."
},
"SEMREL_PLUGIN_TAG_MESSAGE": {
"type": "string",
"description": "Optional annotated tag message."
},
"SEMREL_PLUGIN_SIGN_TAG": {
"type": "string",
"enum": [
"true",
"false",
"1",
"0"
],
"default": "false",
"description": "When true, create a signed tag."
},
"SEMREL_PLUGIN_SIGNED_OFF_BY": {
"type": "string",
"enum": [
"true",
"false",
"1",
"0"
],
"default": "false",
"description": "When true, add a Signed-off-by line to the release commit."
},
"SEMREL_BRANCH": {
"type": "string",
"description": "Release branch name for the current semrel execution."
},
"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_TAG_PREFIX": {
"type": "string",
"description": "Tag prefix used by semrel core, for example \"v\"."
},
"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