Skip to content

Commit

Permalink
Autogenerate attestation libraries using protoc
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sirish <[email protected]>
  • Loading branch information
adityasaky committed Apr 14, 2023
1 parent a84825a commit 6321c22
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 11 deletions.
49 changes: 49 additions & 0 deletions .github/workflows/make-protos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Generate attestation libraries
on:
push:
branches:
- "main"
schedule:
# There are two reasons we may need to regenerate libraries.
# First, there's an explicit change merged into main. That's caught by the
# other trigger. The second reason is when protoc is updated to a newer
# version (still within the versions specified here, as 3.x may map to 3.20
# instead of 3.19) without any changes to the main branch of this
# repository. For this reason, the second trigger runs this workflow once a
# week.
- cron: '0 14 * * 1'
jobs:
run-make-protos:
runs-on: ubuntu-latest
steps:
- name: Install protoc
uses: arduino/setup-protoc@ab6203da1c3118e4406048171b09238ad31ad73e
with:
version: '3.x'
- name: Install Go
uses: actions/setup-go@4d34df0c2316fe8122ab82dc22947d607c0c91f9
with:
go-version: 1.20.x
- name: setup env
run: |
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Checkout repo
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: Generate libraries
run: |
make protos
- name: Create PR
# This step opens a PR if make protos resulted in a difference from
# what's currently in the main branch. It has no permissions to write to
# the repository, maintainers are required to approve and merge the PRs.
uses: peter-evans/create-pull-request@5b4a9f6a9e2af26e5f02351490b90d01eb8ec1e5
with:
commit-message: Regenerate attestation libraries
title: Regenerate attestation libraries
body: This PR updates the attestation libraries generated using protoc.
base: main
branch: actions-regenerate-attestation-libraries
delete-branch: true
signoff: true
author: GitHub <[email protected]>
committer: GitHub <[email protected]>
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
go_setup:
go get google.golang.org/protobuf/cmd/[email protected]
go install google.golang.org/protobuf/cmd/[email protected]

protos: go_setup
make -C protos go
Expand Down
15 changes: 5 additions & 10 deletions docs/protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,11 @@ the message type [update guidelines].
## Regenerating Go proto libraries

[It's typical to keep generated Go code in the repository itself](https://go.dev/doc/articles/go_command#:~:text=and%20then%20check%20those%20generated%20source%20files%20into%20your%20repository)
since it makes users' lives much easier.

Proto libraries should be regenerated & committed after any change to the
proto files. From the root directory, run:

```shell
$ make protos
$ git commit -asm "update protos"
...
```
since it makes users' lives much easier. However, to ensure libraries are
generated using consistent tooling, we have
[automated their generation](/.github/workflows/make-protos.yml). Therefore, if
your change modifies or adds protos, do NOT regenerate and check in the
libraries. After your change is merged, they will be regenerated automatically.

## Run the Go example

Expand Down

0 comments on commit 6321c22

Please sign in to comment.