Skip to content

Commit 15d8815

Browse files
committed
feat: add buf schema registry for proto publishing
- Add buf.yaml with lint rules and breaking change detection - Add buf.gen.yaml for multi-language client generation (Go, Python, TS, Java) - Update CI to lint protos and detect breaking changes on PRs - Update release workflow to auto-publish schema to buf.build/identikey/recrypt - Bundle proto definitions in release artifacts - Ignore gen/ directory for local code generation
1 parent b2d0507 commit 15d8815

File tree

5 files changed

+98
-2
lines changed

5 files changed

+98
-2
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,25 @@ env:
1111
RUSTFLAGS: "-D warnings"
1212

1313
jobs:
14+
proto:
15+
name: Proto Lint & Breaking
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Buf Setup
21+
uses: bufbuild/buf-setup-action@v1
22+
23+
- name: Buf Lint
24+
run: buf lint
25+
26+
- name: Buf Breaking Change Detection
27+
uses: bufbuild/buf-breaking-action@v1
28+
with:
29+
against: "https://github.com/${{ github.repository }}.git#branch=main"
30+
# Only check breaking changes on PRs, not on main pushes
31+
if: github.event_name == 'pull_request'
32+
1433
fmt:
1534
name: Format
1635
runs-on: ubuntu-latest

.github/workflows/release.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ jobs:
197197
cp target/${{ matrix.target }}/release/recrypt-server dist/
198198
cp target/${{ matrix.target }}/release/recrypt dist/
199199
chmod +x dist/recrypt-server dist/recrypt
200+
201+
# Include proto definitions for client generation
202+
mkdir -p dist/proto
203+
cp crates/recrypt-proto/proto/recrypt.proto dist/proto/
200204
201205
cd dist
202206
tar -czvf ../recrypt-${{ steps.version.outputs.version }}-${{ matrix.target }}.tar.gz *
@@ -208,6 +212,10 @@ jobs:
208212
New-Item -ItemType Directory -Path dist -Force | Out-Null
209213
Copy-Item target/${{ matrix.target }}/release/recrypt-server.exe dist/
210214
Copy-Item target/${{ matrix.target }}/release/recrypt.exe dist/
215+
216+
# Include proto definitions for client generation
217+
New-Item -ItemType Directory -Path dist/proto -Force | Out-Null
218+
Copy-Item crates/recrypt-proto/proto/recrypt.proto dist/proto/
211219
212220
Compress-Archive -Path dist/* -DestinationPath recrypt-${{ steps.version.outputs.version }}-${{ matrix.target }}.zip
213221
@@ -234,10 +242,27 @@ jobs:
234242
recrypt-${{ steps.version.outputs.version }}-${{ matrix.target }}.${{ matrix.archive_ext }}.sha256
235243
if-no-files-found: error
236244

245+
publish-proto:
246+
name: Publish Proto to Buf Registry
247+
runs-on: ubuntu-latest
248+
# Only publish on actual releases, not test builds
249+
if: github.event_name != 'workflow_dispatch'
250+
steps:
251+
- uses: actions/checkout@v4
252+
253+
- name: Buf Setup
254+
uses: bufbuild/buf-setup-action@v1
255+
256+
- name: Buf Push
257+
uses: bufbuild/buf-push-action@v1
258+
with:
259+
buf_token: ${{ secrets.BUF_TOKEN }}
260+
237261
release:
238262
name: Create Release
239-
needs: build
240-
if: always() && !cancelled()
263+
needs: [build]
264+
# publish-proto runs in parallel but shouldn't block release
265+
if: always() && !cancelled() && needs.build.result != 'failure'
241266
runs-on: ubuntu-latest
242267

243268
steps:

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ vendor/openfhe-install/
3737
vendor/liboqs-install/
3838
# HumanLayer thoughts (local only)
3939
thoughts/
40+
41+
# Buf generated code (use buf.build registry instead)
42+
gen/

buf.gen.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Buf code generation configuration
2+
# See: https://buf.build/docs/configuration/v2/buf-gen-yaml
3+
#
4+
# Usage: buf generate
5+
# This generates client code for multiple languages from the proto definitions.
6+
version: v2
7+
8+
managed:
9+
enabled: true
10+
override:
11+
- file_option: go_package_prefix
12+
value: github.com/identikey/recrypt/gen/go
13+
14+
plugins:
15+
# Go
16+
- remote: buf.build/protocolbuffers/go
17+
out: gen/go
18+
opt: paths=source_relative
19+
20+
# Python
21+
- remote: buf.build/protocolbuffers/python
22+
out: gen/python
23+
24+
# TypeScript (connect-es for modern TS/JS)
25+
- remote: buf.build/connectrpc/es
26+
out: gen/ts
27+
opt: target=ts
28+
29+
# Java
30+
- remote: buf.build/protocolbuffers/java
31+
out: gen/java

buf.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Buf configuration for protobuf schema management
2+
# See: https://buf.build/docs/configuration/v2/buf-yaml
3+
version: v2
4+
5+
modules:
6+
- path: crates/recrypt-proto/proto
7+
name: buf.build/identikey/recrypt
8+
9+
lint:
10+
use:
11+
- STANDARD
12+
except:
13+
# We use BACKEND_UNKNOWN = 0 intentionally as the unspecified value
14+
- ENUM_ZERO_VALUE_SUFFIX
15+
16+
breaking:
17+
use:
18+
- FILE

0 commit comments

Comments
 (0)