Skip to content

Commit

Permalink
Add protobuf generated code for Go (#12)
Browse files Browse the repository at this point in the history
* add proto code gen

Signed-off-by: Asra Ali <[email protected]>
  • Loading branch information
asraa authored Nov 14, 2022
1 parent d8064a7 commit 7bcfe5e
Show file tree
Hide file tree
Showing 15 changed files with 2,181 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pb.go linguist-generated
42 changes: 42 additions & 0 deletions .github/workflows/generate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright 2022 The Sigstore Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: Generate code

permissions:
contents: read

on:
push:
paths:
- '**.proto'
pull_request:
paths:
- '**.proto'

jobs:
generate_go:
name: Generate go code
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3

- name: Compile protobuf
run: |
make proto
- name: Ensure no files were modified as a result of the codegen
run: git update-index --refresh && git diff-index --quiet HEAD -- || git diff --exit-code
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# This Dockerfile only exists to trigger Dependabot to update this tooling
# dependency.
FROM namely/protoc-all@sha256:07f1ba9dbe11f5675e2efc8617c9552217dc4c3eb5ccd108f7c3889878dbae50 # v1.50_0
21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#
# Copyright 2022 The Sigstore Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PROTOC_IMAGE=$(shell cat Dockerfile | grep FROM | cut -d' ' -f2)

# generate Go protobuf code
proto:
@echo "Generating Protobuf files"
docker run --pull always --platform linux/amd64 -v ${PWD}:/defs ${PROTOC_IMAGE} -i protos -f envelope.proto -f sigstore_bundle.proto -f sigstore_common.proto -f sigstore_rekor.proto -l go --go-module-prefix github.com/sigstore/protobuf-specs/gen/pb-go
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
# protobuf-specs

This repository holds protobuf specifications for Sigstore messages.

## Protobuf

If you change protobuf definitions, you will need to regenerate the code by running the protocol buffer compiler on the changed `.proto` files.

You will need [Docker](https://docs.docker.com/get-docker/) installed to generate the protobuf stubs. Then run,

```
$ make proto
```

to generate the `*.pb.go` files under `gen/`.
Loading

0 comments on commit 7bcfe5e

Please sign in to comment.