Code Monkey home page Code Monkey logo

infranyx / protohub-template Goto Github PK

View Code? Open in Web Editor NEW
18.0 0.0 1.0 84 KB

ProtoHub template is a ProtoHub for storing and building Protocol Buffers (protos) in a pipeline. Golang microservice example Template of this repository is https://github.com/infranyx/go-microservice-template.

License: MIT License

Makefile 100.00%
protobuffer protobuf bufbuild proto golang nodejs rust buf boilerplate template automation pipeline action cicd

protohub-template's Introduction

ProtoHub Template

Table of Contents

ProtoHub template is a ProtoHub for storing and building Protocol Buffers (protos) in a pipeline. It allows other projects to easily import the generated code, reducing the need to maintain duplicate copies of the same protos in multiple repositories. ProtoHub supports both GitLab and GitHub for hosting and running the pipeline.

Features

  • Store protos in a central location
  • Build protos automatically as part of the pipeline
  • Generate code in multiple languages (currently only supporting Go)
  • Use the Buf CLI to lint, validate, and build your protos (optional)

Prerequisites

  • GitLab or GitHub instance with a pipeline set up
  • Repository to store the generated code
  • Buf CLI (optional, only needed if you want to use it for linting and validation)

Getting Started

  1. Set up a pipeline in your GitLab or GitHub instance and specify the repository where the generated code should be pushed.
  2. Clone the ProtoHub repository:
git clone https://github.com/infranyx/protohub-template.git
  1. Navigate to the directory:
cd proto-hub
  1. Add your protos to your sepcifc directory (each Namespace can have directory).
  2. If you want to use the Buf CLI for linting and validation, create a buf.yaml file in the root directory of the repository. This file specifies the configuration for the Buf CLI. For more information on the available configuration options, see the Buf CLI documentation.
  3. If you want to customize the code generation process, create a buf.gen.yaml file in the root directory of the repository. This file specifies the configuration for the code generation process. For more information on the available configuration options, see the Buf CLI documentation.
  4. Push your changes to the repository to trigger the pipeline. The pipeline will handle the code generation process and push the generated code to the specified repository as a separate module (project).
  5. Use the go get command to retrieve the generated code in your project:
go get github.com/<your_username>/<generated_code_repository>
  1. Import the generated code in your project:
import (
  "github.com/<your_username>/<generated_code_repository>"
)

Versioning

ProtoHub uses semantic versioning to version the generated code. When a new release is created, the pipeline uses the git tag and git push commands to create and push a new tag to the repository. The tag will be in the format vX.Y.Z, where X is the major version, Y is the minor version, and Z is the patch version.

  • When merging to the dev branch, a patch release will be createdand the patch version will be incremented.
  • When merging to the main branch, a minor release will be created and the minor version will be incremented.

For example, if the current version is v1.2.3, merging to the dev branch will create a new release with the version v1.2.4. Merging to the main branch will create a new release with the version v1.3.0.

CI/CD

ProtoHub uses GitLab CI/CD to automate the code generation process. The .gitlab-ci.yml file in the root directory of the repository specifies the steps of the pipeline.

  • The lint stage runs the Buf CLI to lint the protos.
  • The build stage generates the code and stores it in the gen/ directory.
  • The push stage pushes the generated code to the specified repository.

The pipeline will only run on the dev and main branches, with the exception of merge request closures.

Github Action

ProtoHub uses Github Action to automate the code generation process. In future proccess it will be much like the gitlab-ci.

Customization

You can customize the code generation process by creating a buf.gen.yaml file in the root directory of the repository. This file allows you to specify the language and output directory for the generated code, as well as any additional plugins or options. For more information on the available configuration options, see the Buf CLI documentation.

References

protohub-template's People

Contributors

amiraladev avatar samannsr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

amiraladev

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.