Skip to content

Commit 1d1f85b

Browse files
committed
Add "version lock" mechanism to proto files
Because dapr/dapr is not registered in the buf registry we can't leverage of it's version locking capability. This should make it safe to only pull new changes when desired for now. Signed-off-by: Tiago Scolari <[email protected]>
1 parent af653b4 commit 1d1f85b

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

.dapr-proto-ref

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ac5845ff5c5617c4c949c82e4e331dca5dddfc8d

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,21 @@ modtidy:
6464

6565
.PHONY: proto
6666
proto:
67-
@rm -rf ./internal/proto/*
68-
@buf generate \
67+
@if [ ! -f .dapr-proto-ref ]; then echo "No .dapr-proto-ref file found. Run 'make proto-update' first."; exit 1; fi
68+
@find ./internal/proto -type f -name '*.go' -delete
69+
@COMMIT=$$(cat .dapr-proto-ref | tr -d '\n'); \
70+
buf generate \
6971
--template buf.gen.yaml \
7072
--path dapr/proto/common/v1 \
7173
--path dapr/proto/runtime/v1 \
72-
'https://github.com/dapr/dapr.git'
74+
"https://github.com/dapr/dapr.git#commit=$$COMMIT"
75+
76+
.PHONY: proto-update
77+
proto-update:
78+
@echo "Updating Dapr to latest commit..."
79+
@git ls-remote https://github.com/dapr/dapr.git HEAD | cut -f1 > .dapr-proto-ref
80+
@echo "Updated .dapr-proto-ref to: $$(cat .dapr-proto-ref)"
81+
@$(MAKE) proto
7382

7483
PROTO_PATH := internal/proto
7584
.PHONY: proto-check-diff

internal/proto/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Dapr Protos
2+
3+
These are generated protos from the [Dapr](https://github.com/dapr/dapr/tree/master/dapr) repository.
4+
5+
They are version locked using the [.dapr-proto-ref](../../.dapr-proto-ref) file.
6+
7+
### Bumping the version of the proto files
8+
9+
The command `make proto-update` makes it easier to bump the proto files version.
10+
11+
### Generating protos
12+
13+
To generate the protos, using the current locked version, use the command `make proto`

0 commit comments

Comments
 (0)