A repository for managing Protocol Buffers definitions and generating Go and Java code.
idl/
├── proto/
│ └── services/ # Service-specific proto definitions
│ └── search/
│ └── search.proto
├── gen/ # Generated code
│ ├── go/
│ │ └── apis/v1/
│ │ └── search/
│ └── java/
│ └── apis/v1/
│ └── search/
├── scripts/ # Code generation and deployment scripts
├── docker/ # Docker build environment
└── Makefile # Docker-based build commands
- Docker and Docker Compose
- Git
All code generation runs inside Docker containers, so you don't need to install protoc, Go, or Java locally.
Follow these steps to get started with the project:
-
Clone the repository
git clone <repository-url> cd idl
-
Build Docker image
make docker-build
-
Generate code
make gen
-
Verify generated code
ls -la gen/go/apis/v1/ ls -la gen/java/apis/v1/
How to generate and test code in your local development environment.
make docker-buildThis command builds a development environment image using docker/Dockerfile. The image includes all necessary tools such as protoc, Go, Java, and Maven.
make genThis command detects changed services by comparing proto and gen directories with the previous commit, and generates Go and Java code only for those services.
make gen-allGenerates Go and Java code for all services. The generated code is stored in the gen/ directory.
export GITHUB_TOKEN="your_github_token"
export GITHUB_REPOSITORY="your_username/idl" # 예: kkdeok/idl
make publishThis command:
- Detects changed services by comparing proto and gen directories with the previous commit
- Creates and pushes git tags for Go packages (format:
{service}-v{version}) - Publishes Java packages to GitHub Packages
export GITHUB_TOKEN="your_github_token"
export GITHUB_REPOSITORY="your_username/idl"
make publish-allNote:
GITHUB_TOKENis required for pushing tags and publishing to GitHub Packages- You can create a Personal Access Token (PAT) with
repoandwrite:packagespermissions GITHUB_REPOSITORYshould be in the formatowner/repo(e.g.,kkdeok/idl)
To run commands directly inside the container:
make docker-shellInside the container, you can run scripts directly such as ./scripts/gen_go.sh or ./scripts/gen_java.sh.
-
Create a new directory under
proto/services/mkdir -p proto/services/newservice
-
Write proto file
syntax = "proto3"; package apis.v1.newservice; option java_package = "com.kkdeok.idl.apis.v1.newservice"; option java_multiple_files = true; option java_outer_classname = "NewServiceProto"; option go_package = "gen/go/apis/v1/newservice;newservice"; service NewService { rpc DoSomething(NewServiceRequest) returns (NewServiceResponse); } message NewServiceRequest { string data = 1; } message NewServiceResponse { string result = 1; }
-
Generate code
make gen
Generated code is automatically published to GitHub Packages.
<!-- pom.xml -->
<repositories>
<repository>
<id>github</id>
<url>https://maven.pkg.github.com/kkdeok/idl</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.nextsecurities.idl</groupId>
<artifactId>idl-search-v1</artifactId>
<version>0.0.1</version>
</dependency>
</dependencies>import com.kkdeok.idl.apis.v1.search.SearchProto.SearchRequest;
import com.kkdeok.idl.apis.v1.search.SearchProto.SearchResponse;
SearchRequest request = SearchRequest.newBuilder()
.setQuery("test")
.build();import (
"gen/go/apis/v1/search"
)
request := &search.SearchRequest{
Query: "test",
}-
Build Docker image (first time only)
make docker-build
-
Modify proto files in
proto/services/{service}/ -
Generate code for changed services
make gen
Or generate for all services:
make gen-all
-
Commit and push changes
git add . git commit -m "Update proto files" git push
-
Publish changed services (requires GitHub token)
export GITHUB_TOKEN="your_github_token" export GITHUB_REPOSITORY="your_username/idl" make publish
GITHUB_TOKEN: GitHub Personal Access Token withrepoandwrite:packagespermissionsGITHUB_REPOSITORY: Repository in formatowner/repo(e.g.,kkdeok/idl)BASE_SHA(optional): Base commit SHA for comparison (defaults to previous commit)HEAD_SHA(optional): Head commit SHA for comparison (defaults toHEAD)
When you push to the main branch, GitHub Actions automatically:
- Detects changed services
- Generates and validates code
- Creates service-specific version tags
- Publishes Java packages to GitHub Packages
Service versions are managed in the format {service}-v{version} (e.g., search-v0.0.1).
- Each service is versioned independently
- For breaking changes, create a new version directory (e.g.,
services/search/v2/)