|
1 | | -# {{PLUGIN_NAME}} |
| 1 | +# plugin-template |
2 | 2 |
|
3 | | -[](https://github.com/SemRels/{{PLUGIN_NAME}}/releases/latest) |
| 3 | +[](https://github.com/SemRels/plugin-template/releases/latest) |
| 4 | +[](https://github.com/SemRels/plugin-template/actions/workflows/ci.yml) |
| 5 | +[](LICENSE) |
| 6 | +[](https://scorecard.dev/viewer/?uri=github.com/SemRels/plugin-template) |
| 7 | +[](https://api.reuse.software/info/github.com/SemRels/plugin-template) |
4 | 8 |
|
5 | | -> Replace this description with what your SemRel plugin does. |
| 9 | +Template repository for SemRels plugins built as standalone Go subprocess binaries. |
6 | 10 |
|
7 | | -This repository is based on the `SemRels/plugin-template` GitHub template and provides a clean starting point for provider, analyzer, generator, updater, or hook plugins. |
| 11 | +This template reflects the current SemRels plugin architecture: semrel executes a plain Go CLI binary as a subprocess, passes plugin configuration through `SEMREL_PLUGIN_*` variables, passes release context through `SEMREL_*` variables, reads plugin output from standard output, and treats exit code `0` as success and any non-zero exit code as failure. There is no gRPC transport, no network listener, and no protobuf plumbing to wire up. |
8 | 12 |
|
9 | | -## Repository Layout |
| 13 | +## What the example plugin does |
| 14 | + |
| 15 | +The scaffolded example is intentionally phase-agnostic. It reads `SEMREL_VERSION` and `SEMREL_DRY_RUN`, writes the required schema handshake to standard error, and prints a confirmation message to standard output: |
10 | 16 |
|
11 | 17 | ```text |
12 | | -cmd/plugin/ Plugin entry point |
13 | | -internal/plugin/ Business logic scaffold |
14 | | -internal/grpc/ gRPC transport scaffold |
15 | | -proto/v1 Symlink to the SemRel protobuf contract |
16 | | -.github/workflows/ CI, release, and security automation |
| 18 | +stderr: plugin_schema_version=1 |
| 19 | +stdout: example plugin invoked for version 1.2.3 (dry-run: false) |
17 | 20 | ``` |
18 | 21 |
|
19 | | -## Installation |
| 22 | +## Plugin contract |
| 23 | + |
| 24 | +| Item | Behavior | |
| 25 | +| --- | --- | |
| 26 | +| `plugin_schema_version=1` | The **first line written to stderr** must be `plugin_schema_version=1`. | |
| 27 | +| `SEMREL_VERSION` | Required release version for this example plugin. | |
| 28 | +| `SEMREL_DRY_RUN` | Optional boolean (`true`/`false`) indicating dry-run mode. | |
| 29 | +| `SEMREL_PLUGIN_*` | Reserved for your phase-specific plugin configuration. | |
| 30 | +| stdout | Write the plugin's functional output here. | |
| 31 | +| stderr | Write diagnostics, validation errors, and logs here. | |
| 32 | +| exit code | `0` means success; any non-zero code means failure. | |
| 33 | + |
| 34 | +## Repository layout |
20 | 35 |
|
21 | | -Published binaries are distributed through releases and synchronized to `registry.semrel.io`. |
| 36 | +```text |
| 37 | +cmd/plugin/ Thin environment-variable wrapper and process entry point |
| 38 | +internal/plugin/ Pure, testable plugin logic with no os/env dependencies |
| 39 | +.github/workflows/ CI, release, security, template-sync, and semrel self-release automation |
| 40 | +.semrel.yaml semrel dogfooding configuration for this repository |
| 41 | +``` |
22 | 42 |
|
23 | | -## Development |
| 43 | +## Use this template for a real plugin |
| 44 | + |
| 45 | +1. Create a new repository from this template or copy it into your plugin repository. |
| 46 | +2. Rename the Go module in `go.mod` to `github.com/SemRels/<your-plugin-repo>`. |
| 47 | +3. Rename the binary/package descriptions from `plugin-template` to your plugin name. |
| 48 | +4. Implement your phase-specific logic in `internal/plugin/` as pure Go. |
| 49 | +5. Keep `cmd/plugin/main.go` thin: read `SEMREL_*` / `SEMREL_PLUGIN_*` with `os.Getenv` (or an injected `getenv` in tests), translate them into a config struct, then call the internal package. |
| 50 | +6. Extend the README tables with every `SEMREL_PLUGIN_*` and `SEMREL_*` variable your plugin consumes. |
| 51 | +7. Update `.semrel.yaml` and replace the example phase assignment comments/configuration with the plugins and phases your real plugin release process needs. |
| 52 | + |
| 53 | +## Local development |
24 | 54 |
|
25 | 55 | ```bash |
26 | | -go build ./cmd/plugin |
| 56 | +go build ./... |
27 | 57 | go test ./... |
28 | 58 | ``` |
29 | 59 |
|
30 | | -## Configuration |
| 60 | +## Example semrel configuration |
31 | 61 |
|
32 | | -See the SemRel documentation for plugin configuration and runtime integration details: |
33 | | - |
34 | | -- https://github.com/SemRels/semrel |
35 | | -- https://registry.semrel.io |
| 62 | +```yaml |
| 63 | +plugins: |
| 64 | + - name: example-plugin |
| 65 | + path: ~/.semrel/plugins/semrel-plugin-example |
| 66 | + env: |
| 67 | + SEMREL_PLUGIN_SAMPLE_OPTION: "value" |
| 68 | +``` |
36 | 69 |
|
37 | | -## Next Steps |
| 70 | +## License |
38 | 71 |
|
39 | | -1. Replace all `{{...}}` placeholders. |
40 | | -2. Rename the module path in `go.mod`. |
41 | | -3. Implement your plugin logic in `internal/plugin/`. |
42 | | -4. Wire generated protobuf bindings into `internal/grpc/`. |
43 | | -5. Create your first tagged release with `v*.*.*`. |
| 72 | +Apache-2.0 |
0 commit comments