diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index cd44d8c..952d709 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -41,6 +41,35 @@ jobs: run: gh release create "$GITHUB_REF_NAME" --title "Release $GITHUB_REF_NAME" --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # The BSR remote plugin, so consumers can use `remote: buf.build/roderm/ + # go-sqlmap` instead of installing the binary. Runs after `release` because + # buf.plugin.yaml's license_url points at the tag's LICENSE. + plugin: + runs-on: ["ubuntu-latest"] + needs: release + steps: + - uses: actions/checkout@v4 + - uses: bufbuild/buf-setup-action@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + # buf.plugin.yaml pins the runtime module the generated code imports. + # Publishing it out of step with the tag would ship a plugin whose + # generated SDKs require a module version that does not exist. + - name: Check buf.plugin.yaml is in step with the tag + run: | + pinned=$(awk '/^plugin_version:/ {print $2}' buf.plugin.yaml) + if [ "$pinned" != "$GITHUB_REF_NAME" ]; then + echo "::error::buf.plugin.yaml plugin_version is $pinned, tag is $GITHUB_REF_NAME" + exit 1 + fi + if ! grep -q "version: $GITHUB_REF_NAME\$" buf.plugin.yaml; then + echo "::error::buf.plugin.yaml does not pin the runtime module at $GITHUB_REF_NAME" + exit 1 + fi + - name: Push the remote plugin + run: buf beta registry plugin push --visibility=public + env: + BUF_TOKEN: ${{ secrets.BUF_TOKEN }} builds: runs-on: ["ubuntu-latest"] needs: release diff --git a/CLAUDE.md b/CLAUDE.md index cf3486c..a0de45b 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -10,6 +10,19 @@ The goal is a set of independently switchable plugins over one shared `TableRepo Plugins are toggled with the `plugins=` protoc parameter, a **`+`-separated** list (protoc already uses `,` between parameters): `--go-sqlmap_out=plugins=schema+scanner:.`. Omitting it enables everything. `plugins` entries live in one slice in `generator.go`; `query` declares `Requires: ["scanner"]` because its output calls the scanner's `Result` type, and enabling it alone is a generation-time error rather than uncompilable Go. +### BSR remote plugin + +`buf.plugin.yaml` + `Dockerfile` publish the generator as `buf.build/roderm/go-sqlmap`, so consumers need no local binary: + +```yaml +plugins: + - remote: buf.build/roderm/go-sqlmap:v0.1.0 + out: pkg/generated/ + opt: [paths=source_relative, plugins=schema+scanner+query] +``` + +`buf.plugin.yaml` pins the runtime module the generated code imports (`pkg/query`, `pkg/generated/schema/v1`), so `plugin_version` and `registry.go.deps` must both match the git tag — the release workflow fails if they drift. Publishing happens in CI on tag (`buf beta registry plugin push`, needs `BUF_TOKEN`); it is a separate resource from the `buf.build/roderm/protoc-gen-go-sqlmap` *module* that carries the protos. Test the image locally with `docker build -t x . && protoc --plugin=protoc-gen-y=