Skip to content

Commit 10b7a6c

Browse files
committed
feat(plugins): RunStdio against published SDK; bump go; CI and release workflows
1 parent 897f77c commit 10b7a6c

13 files changed

Lines changed: 795 additions & 1029 deletions

File tree

.github/workflows/ci.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Plugins CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
plugin: [echo, weather, githooks]
19+
steps:
20+
- name: Checkout marchat-plugins
21+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
22+
with:
23+
path: marchat-plugins
24+
25+
- name: Checkout marchat (for replace path)
26+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
27+
with:
28+
repository: Cod-e-Codes/marchat
29+
path: marchat
30+
31+
- name: Set up Go
32+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
33+
with:
34+
go-version: '1.25.9'
35+
36+
- name: Lint and test (${{ matrix.plugin }})
37+
env:
38+
GOTOOLCHAIN: auto
39+
run: |
40+
set -euo pipefail
41+
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
42+
go install golang.org/x/vuln/cmd/govulncheck@latest
43+
LINT="$(go env GOPATH)/bin/golangci-lint"
44+
VULN="$(go env GOPATH)/bin/govulncheck"
45+
cd "${GITHUB_WORKSPACE}/marchat-plugins/plugins/${{ matrix.plugin }}"
46+
go mod tidy
47+
out="$(gofmt -l .)"
48+
if [ -n "$out" ]; then echo "Unformatted:"; echo "$out"; exit 1; fi
49+
go build ./...
50+
go test ./... -count=1
51+
go vet ./...
52+
"$VULN" -show verbose ./...
53+
"$LINT" run ./...

.github/workflows/release.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
name: Release plugin archives
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
plugin:
7+
description: 'Plugin directory under plugins/'
8+
required: true
9+
type: choice
10+
options:
11+
- echo
12+
- weather
13+
- githooks
14+
plugin_version:
15+
description: 'Version embedded in zip names (e.g. 2.0.2)'
16+
required: true
17+
release_tag:
18+
description: 'GitHub release tag to create or upload to (e.g. v2.0.2)'
19+
required: true
20+
21+
permissions:
22+
contents: write
23+
24+
jobs:
25+
build-and-upload:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- name: Checkout marchat-plugins
29+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
30+
with:
31+
path: marchat-plugins
32+
33+
- name: Checkout marchat (sibling for go.mod replace)
34+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
35+
with:
36+
repository: Cod-e-Codes/marchat
37+
path: marchat
38+
39+
- name: Set up Go
40+
uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5
41+
with:
42+
go-version: '1.25.9'
43+
44+
- name: Install zip
45+
run: sudo apt-get update && sudo apt-get install -y zip
46+
47+
- name: Build all targets
48+
env:
49+
GH_TOKEN: ${{ github.token }}
50+
PLUGIN: ${{ github.event.inputs.plugin }}
51+
VERSION: ${{ github.event.inputs.plugin_version }}
52+
TAG: ${{ github.event.inputs.release_tag }}
53+
run: |
54+
set -euo pipefail
55+
ROOT="${GITHUB_WORKSPACE}/marchat-plugins"
56+
cd "${ROOT}/plugins/${PLUGIN}"
57+
go mod tidy
58+
for pair in windows/amd64 linux/amd64 linux/arm64 darwin/amd64 darwin/arm64; do
59+
export GOOS="${pair%/*}"
60+
export GOARCH="${pair#*/}"
61+
export VERSION
62+
bash build.sh
63+
done
64+
echo "Built archives:"
65+
ls -la dist/*.zip
66+
if ! command -v gh >/dev/null 2>&1; then
67+
echo "gh CLI missing" >&2
68+
exit 1
69+
fi
70+
cd "${ROOT}"
71+
if gh release view "${TAG}" >/dev/null 2>&1; then
72+
echo "Uploading to existing release ${TAG}"
73+
else
74+
gh release create "${TAG}" --title "${TAG}" --generate-notes
75+
fi
76+
shopt -s nullglob
77+
files=( "plugins/${PLUGIN}/dist/"*.zip )
78+
if [ "${#files[@]}" -eq 0 ]; then
79+
echo "No zip files to upload" >&2
80+
exit 1
81+
fi
82+
gh release upload "${TAG}" "${files[@]}" --clobber

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ Or install directly:
3535

3636
## Publishing plugins
3737

38-
When publishing a new plugin release, build and upload one archive per target platform and provide the corresponding checksums. A typical process:
38+
### Automated (GitHub Actions)
39+
40+
Use **Actions** then **Release plugin archives** (`release.yml`). Pick the plugin folder (`echo`, `weather`, or `githooks`), the **plugin version** string that appears inside each zip name, and the **GitHub release tag** to create or append to. The workflow checks out this repo plus [marchat](https://github.com/Cod-e-Codes/marchat) as a sibling (for the `go.mod` `replace` on `plugin/sdk`), runs each platform `build.sh`, then creates the tag if missing and uploads all `dist/*.zip` files with `gh release upload`. You still need to refresh `registry.json` checksums and URLs after publishing (see `REGISTRY.md` and `collect-checksums.sh` / `collect-checksums.ps1`).
41+
42+
### Manual
43+
44+
When publishing without CI, build and upload one archive per target platform and provide the corresponding checksums. A typical process:
3945

4046
1. Build platform-specific archives (see `plugins/echo/README.md` for examples and scripts):
4147
- `echo-plugin-v2.0.1-windows-amd64.zip`

REGISTRY.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
# Registry: publishing platform-specific plugins
2-
3-
This repository hosts a simple JSON registry (`registry.json`) that points to downloadable plugin archives. With the single-binary model, each plugin release contains one archive targeted to a specific OS/architecture.
4-
5-
## Steps to publish
6-
7-
1. Build the platform-specific archive
8-
- Use the scripts under your plugin directory (example: `plugins/echo`):
9-
- Windows (PowerShell): `./build.ps1 -Version 1.0.0 -Os windows -Arch amd64`
10-
- Linux/macOS (Bash): `VERSION=1.0.0 GOOS=linux GOARCH=amd64 bash build.sh`
11-
- Output: `dist/<name>-plugin-v<version>-<goos>-<goarch>.zip` and a matching `.sha256` file.
12-
13-
2. Upload the archive to your release hosting
14-
- Example: GitHub Releases for `marchat-plugins`.
15-
- Copy the final download URL of the uploaded archive.
16-
17-
3. Capture the SHA-256 checksum
18-
- Use the contents of the generated `.sha256` file (the hex digest).
19-
20-
4. Update `registry.json`
21-
- Keep one entry per plugin. Point `download_url` and `checksum` to the specific platform you are publishing.
22-
- Update `version` and `last_updated` accordingly.
23-
24-
### Example `registry.json` entry
25-
```json
26-
{
27-
"version": "1.0.0",
28-
"last_updated": "2025-01-01T00:00:00Z",
29-
"plugins": [
30-
{
31-
"name": "echo",
32-
"version": "1.0.0",
33-
"description": "Simple echo plugin for testing the plugin system",
34-
"author": "Cod-e-Codes",
35-
"homepage": "https://github.com/Cod-e-Codes/marchat",
36-
"download_url": "https://github.com/Cod-e-Codes/marchat-plugins/releases/download/v1.0.0/echo-plugin-v1.0.0-windows-amd64.zip",
37-
"checksum": "sha256:<hex-digest>",
38-
"category": "utility",
39-
"tags": ["chat", "utility", "echo", "test"],
40-
"min_version": "0.2.0-beta.1"
41-
}
42-
]
43-
}
44-
```
45-
46-
Notes:
47-
- The host validates `GOOS/GOARCH` at runtime and will refuse to launch mismatched binaries with a clear error.
48-
- If you need to support multiple platforms, publish separate releases and update `registry.json` to point at the one most relevant for your audience. The store and `:plugin list` remain unchanged.
1+
# Registry: publishing platform-specific plugins
2+
3+
This repository hosts a simple JSON registry (`registry.json`) that points to downloadable plugin archives. With the single-binary model, each plugin release contains one archive targeted to a specific OS/architecture.
4+
5+
## Steps to publish
6+
7+
1. Build the platform-specific archive
8+
- Use the scripts under your plugin directory (example: `plugins/echo`):
9+
- Windows (PowerShell): `./build.ps1 -Version 1.0.0 -Os windows -Arch amd64`
10+
- Linux/macOS (Bash): `VERSION=1.0.0 GOOS=linux GOARCH=amd64 bash build.sh`
11+
- Output: `dist/<name>-plugin-v<version>-<goos>-<goarch>.zip` and a matching `.sha256` file.
12+
13+
2. Upload the archive to your release hosting
14+
- Example: GitHub Releases for `marchat-plugins`.
15+
- Copy the final download URL of the uploaded archive.
16+
17+
3. Capture the SHA-256 checksum
18+
- Use the contents of the generated `.sha256` file (the hex digest).
19+
20+
4. Update `registry.json`
21+
- Keep one entry per plugin. Point `download_url` and `checksum` to the specific platform you are publishing.
22+
- Update `version` and `last_updated` accordingly.
23+
24+
### Example `registry.json` entry
25+
```json
26+
{
27+
"version": "1.0.0",
28+
"last_updated": "2025-01-01T00:00:00Z",
29+
"plugins": [
30+
{
31+
"name": "echo",
32+
"version": "1.0.0",
33+
"description": "Simple echo plugin for testing the plugin system",
34+
"author": "Cod-e-Codes",
35+
"homepage": "https://github.com/Cod-e-Codes/marchat",
36+
"download_url": "https://github.com/Cod-e-Codes/marchat-plugins/releases/download/v1.0.0/echo-plugin-v1.0.0-windows-amd64.zip",
37+
"checksum": "sha256:<hex-digest>",
38+
"category": "utility",
39+
"tags": ["chat", "utility", "echo", "test"],
40+
"min_version": "0.2.0-beta.1"
41+
}
42+
]
43+
}
44+
```
45+
46+
Notes:
47+
- The host validates `GOOS/GOARCH` at runtime and will refuse to launch mismatched binaries with a clear error.
48+
- If you need to support multiple platforms, publish separate releases and update `registry.json` to point at the one most relevant for your audience. The store and `:plugin list` remain unchanged.

0 commit comments

Comments
 (0)