update CI workflow to install specific protoc version and enhance generated Protobufs handling
This commit is contained in:
1 parent
35d0739b63
commit
ce2c54acf2
3 files changed
+32
-13
No files matched your search
@@ -17,7 +17,7 @@ jobs:
|
|||||||
uses: actions/checkout@v7
|
uses: actions/checkout@v7
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.head.sha || github.sha }}
|
||||||
|
|
||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v7
|
uses: actions/setup-go@v7
|
||||||
@@ -26,21 +26,37 @@ jobs:
|
|||||||
|
|
||||||
- name: Install protoc
|
- name: Install protoc
|
||||||
run: |
|
run: |
|
||||||
sudo apt-get update
|
curl --fail --location --silent --show-error \
|
||||||
sudo apt-get install -y protobuf-compiler
|
--output "$RUNNER_TEMP/protoc.zip" \
|
||||||
|
https://github.com/protocolbuffers/protobuf/releases/download/v36.2/protoc-36.2-linux-x86_64.zip
|
||||||
|
unzip -q "$RUNNER_TEMP/protoc.zip" -d "$RUNNER_TEMP/protoc"
|
||||||
|
echo "$RUNNER_TEMP/protoc/bin" >> "$GITHUB_PATH"
|
||||||
|
|
||||||
- name: Install protoc-gen-go
|
- name: Install protoc-gen-go
|
||||||
run: |
|
run: |
|
||||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12
|
||||||
|
|
||||||
- name: Generate Protobufs
|
- name: Generate Protobufs
|
||||||
run: |
|
run: |
|
||||||
make proto
|
make proto
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
|
env:
|
||||||
|
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
HEAD_REF: ${{ github.event.pull_request.head.ref }}
|
||||||
|
REPOSITORY: ${{ github.repository }}
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name "actions[bot]"
|
git add -- '*.pb.go'
|
||||||
git config --global user.email "noreply@beejay.kim"
|
if git diff --cached --quiet; then
|
||||||
git add .
|
exit 0
|
||||||
git commit -m "Update generated Protobufs" || echo "No changes to commit"
|
fi
|
||||||
git push origin ${{ github.ref }} || echo "No changes to push"
|
|
||||||
|
if [ "$HEAD_REPOSITORY" != "$REPOSITORY" ]; then
|
||||||
|
echo "::error::Generated protobufs are out of date. Run make proto and commit the changes."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
git config user.name "actions[bot]"
|
||||||
|
git config user.email "noreply@beejay.kim"
|
||||||
|
git commit -m "Update generated Protobufs"
|
||||||
|
git push origin "HEAD:refs/heads/$HEAD_REF"
|
||||||
@@ -55,13 +55,17 @@ The module requires Go 1.27 and `google.golang.org/protobuf`.
|
|||||||
|
|
||||||
## Regenerating Go code
|
## Regenerating Go code
|
||||||
|
|
||||||
Install `protoc` and the Go generator, and ensure both executables are on
|
Install `protoc` 36.2 using the [official installation
|
||||||
`PATH`:
|
instructions](https://protobuf.dev/installation/), and ensure it and the Go
|
||||||
|
generator are on `PATH`:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
protoc --version
|
||||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12
|
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.36.12
|
||||||
make proto
|
make proto
|
||||||
```
|
```
|
||||||
|
|
||||||
`make proto` regenerates the Go files from both schemas. Commit the updated
|
`make proto` regenerates the Go files from both schemas. Commit the updated
|
||||||
`.pb.go` files together with any schema changes.
|
`.pb.go` files together with any schema changes. The workflow pushes generated
|
||||||
|
files to same-repository pull request branches; for pull requests from forks,
|
||||||
|
it reports an error if generated files are out of date.
|
||||||
@@ -6,7 +6,6 @@ option go_package = "beejay.kim/fog/model";
|
|||||||
enum DeploymentAction {
|
enum DeploymentAction {
|
||||||
STOP = 0;
|
STOP = 0;
|
||||||
START = 1;
|
START = 1;
|
||||||
CLEANUP = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message GlobalEnvironment {
|
message GlobalEnvironment {
|
||||||
|
|||||||
Reference in new issue
Block a user