Skip to content

Commit

Permalink
build(ci): Provide installation scripts for codegen
Browse files Browse the repository at this point in the history
Signed-off-by: jannfis <[email protected]>
  • Loading branch information
jannfis committed Feb 21, 2024
1 parent 2bbe893 commit 877c5bc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 4 deletions.
17 changes: 16 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,26 @@ mod-vendor:
clean:
rm -rf dist/ vendor/ build/

./build/bin/protoc-gen-go:
./hack/install/install-codegen-go-tools.sh

./build/bin/protoc-gen-go-grpc:
./hack/install/install-codegen-go-tools.sh

./build/bin/protoc:
./hack/install/install-protoc.sh

.PHONY: install-protoc-go
install-protoc-go: ./build/bin/protoc-gen-go ./build/bin/protoc-gen-go-grpc

.PHONY: install-protoc
install-protoc: ./build/bin/protoc

.PHONY: codegen
codegen: protogen

.PHONY: protogen
protogen: mod-vendor
protogen: mod-vendor install-protoc-go install-protoc
./hack/generate-proto.sh

.PHONY: lint
Expand Down
3 changes: 2 additions & 1 deletion hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set -eo pipefail

PROJECT_ROOT=$(cd "$(dirname "${BASH_SOURCE}")"/..; pwd)
PATH=${PROJECT_ROOT}/build/bin:${PATH}

GENERATE_PATHS="
${PROJECT_ROOT}/principal/apis/auth;authapi
Expand All @@ -24,7 +25,7 @@ for p in ${GENERATE_PATHS}; do
protoc -I=${src_path} \
-I=${PROJECT_ROOT}/vendor \
-I=${PROJECT_ROOT}/proto \
-I=${PROJECT_ROOT}/dist/protoc-include \
-I=${PROJECT_ROOT}/build/bin/protoc-include \
--go_out=${PROJECT_ROOT}/pkg/api/grpc/${api_name} \
--go_opt=paths=source_relative \
--go-grpc_out=${PROJECT_ROOT}/pkg/api/grpc/${api_name} \
Expand Down
9 changes: 9 additions & 0 deletions hack/install/install-codegen-go-tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

PROJECT_ROOT=$(cd $(dirname ${BASH_SOURCE})/../..; pwd)
DIST_PATH="${PROJECT_ROOT}/build/bin"
mkdir -p "${DIST_PATH}"
export GOBIN="${DIST_PATH}"

go install google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/grpc/cmd/[email protected]
5 changes: 3 additions & 2 deletions hack/install/install-protoc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
set -eux -o pipefail

PROJECT_ROOT=$(cd $(dirname ${BASH_SOURCE})/../..; pwd)
DIST_PATH="${PROJECT_ROOT}/dist"
DIST_PATH="${PROJECT_ROOT}/build/bin"
mkdir -p "${DIST_PATH}"
PATH="${DIST_PATH}:${PATH}"

protoc_version="24.3"
protoc_version="25.3"
OS=$(go env GOOS)
ARCHITECTURE=$(go env GOARCH)
DOWNLOADS=$(mktemp -d /tmp/downloads.XXXXXXXXX)
Expand Down

0 comments on commit 877c5bc

Please sign in to comment.