Skip to content

feat(proto): add Buf Schema Registry support#252

Open
whywaita wants to merge 3 commits intomasterfrom
feat/buf-schema-registry
Open

feat(proto): add Buf Schema Registry support#252
whywaita wants to merge 3 commits intomasterfrom
feat/buf-schema-registry

Conversation

@whywaita
Copy link
Owner

Summary

  • Add Buf (https://buf.build) support for managing protobuf definitions
  • Enable publishing myshoes proto to Buf Schema Registry (BSR)
  • Allow other projects (shoes plugins) to depend on myshoes proto via BSR

Changes

  • Add api/proto/buf.yaml for Buf configuration with lint rules
  • Add api/proto/buf.gen.yaml for code generation settings using remote plugins
  • Add .github/workflows/buf.yaml for CI/CD integration (lint on PR, push on master)
  • Update Makefile:
    • build-proto now uses buf generate instead of protoc directly
    • Add lint-proto target for buf lint
  • Add .buf/ to .gitignore
  • Regenerate proto files with buf generate (only protoc version comment changed)

Test Plan

  • buf lint passes without errors
  • buf build succeeds
  • make build succeeds
  • make test - all tests pass
  • Generated proto code is functionally identical (only version comment differs)

Notes

Manual Steps Required

After merging, the following manual steps are needed to publish to BSR:

  1. BSR Account Setup

    • Create account at https://buf.build
    • Create repository buf.build/whywaita/myshoes
    • Generate API token
    • Add BUF_TOKEN to GitHub Secrets (Settings → Secrets and variables → Actions)
  2. Initial Push

    cd api/proto && buf push

Usage from Other Projects

Once published, other projects can depend on myshoes proto:

# In dependent project's buf.yaml
version: v2
deps:
  - buf.build/whywaita/myshoes

Then use:

buf dep update
buf generate

Add Buf (https://buf.build) support for managing and publishing myshoes protobuf definitions to Buf Schema Registry (BSR).

Changes:
- Add api/proto/buf.yaml for Buf configuration with lint rules
- Add api/proto/buf.gen.yaml for code generation settings
- Add .github/workflows/buf.yaml for CI/CD integration
- Update Makefile to use buf for proto code generation
- Add .buf/ to .gitignore
- Regenerate proto.go files using buf generate

This allows other projects (shoes plugins) to depend on myshoes proto definitions via BSR.

Manual steps required:
1. Create buf.build account and repository (buf.build/whywaita/myshoes)
2. Add BUF_TOKEN to GitHub Secrets
3. Run: cd api/proto && buf push

prompt: Implement the following plan: # myshoes proto を Buf Cloud (BSR) に公開する計画
----
計画内容を実装します。まず、タスクを整理してから作業を開始します。

実装が完了しました。以下のファイルを作成・更新しました:

## 作成したファイル

1. **api/proto/buf.yaml** - Buf の設定ファイル(lint と breaking change のルールを定義)
2. **api/proto/buf.gen.yaml** - コード生成の設定ファイル
3. **.github/workflows/buf.yaml** - GitHub Actions ワークフロー

## 更新したファイル

1. **Makefile** - `build-proto` を buf ベースに変更、`lint-proto` ターゲットを追加
2. **.gitignore** - `.buf/` を追加
3. **api/proto.go/myshoes.pb.go** - buf generate で再生成(protoc バージョン表示のみ変更)
4. **api/proto.go/myshoes_grpc.pb.go** - buf generate で再生成(protoc バージョン表示のみ変更)

## 動作確認

- `buf lint` - エラーなし
- `buf build` - 成功
- `make build` - 成功
- `make test` - すべてのテストが成功

## 次のステップ(手動作業が必要)

BSR に公開するためには、以下の手順を手動で行う必要があります:

1. **BSR アカウントのセットアップ**
   - https://buf.build でアカウントを作成
   - リポジトリ `buf.build/whywaita/myshoes` を作成
   - API トークンを取得
   - GitHub の Settings → Secrets and variables → Actions で `BUF_TOKEN` を登録

2. **初回プッシュ**
   \`\`\`bash
   cd api/proto && buf push
   \`\`\`

3. **他のプロジェクトからの利用**
   公開後、他のプロジェクトは以下のように依存できます:
   \`\`\`yaml
   # 依存先の buf.yaml
   version: v2
   deps:
     - buf.build/whywaita/myshoes
   \`\`\`
@github-actions
Copy link

github-actions bot commented Jan 20, 2026

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJan 20, 2026, 9:14 AM

- Add blank line after package declaration
- Add newline at end of file

This fixes the buf format CI check.
Add buf installation to fix docker build error.
The Makefile now uses 'buf generate' so buf must be available
in the build environment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant