-
Notifications
You must be signed in to change notification settings - Fork 827
93 lines (89 loc) · 3.31 KB
/
Copy pathgenerate-protobuf.yml
File metadata and controls
93 lines (89 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
name: Generate Protobuf
on:
push:
branches:
- "renovate/protobuf"
permissions: {}
jobs:
generate:
runs-on: ubuntu-24.04
permissions:
contents: read # checkout + read-only `git fetch origin main` for the verify step
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
ref: ${{ github.ref }}
persist-credentials: false
- uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0
with:
version: v2026.6.10
sha256: 656131b5d995493c18b06c2135afda193f94a1848e0a4d1cb07a1161859d0c80
- name: Cache local Maven repository
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Verify both protobuf deps are updated
run: |
git fetch origin main
DIFF_POM=$(git diff origin/main -- pom.xml)
DIFF_MISE=$(git diff origin/main -- mise.toml)
if ! echo "$DIFF_POM" | grep -q 'protobuf-java.version'; then
echo "::error::protobuf-java not updated in pom.xml"
exit 1
fi
if ! echo "$DIFF_MISE" | grep -q 'protoc'; then
echo "::error::protoc not updated in mise.toml"
exit 1
fi
- name: Generate protobuf sources
run: mise run generate
- name: Validate and export generated sources as a patch
run: |
UNEXPECTED=$(git diff --name-only | grep -v '\.java$' || true)
if [[ -n "$UNEXPECTED" ]]; then
echo "::error::Unexpected files changed:"
echo "$UNEXPECTED"
exit 1
fi
git diff --binary > /tmp/protobuf-sources.patch
- name: Upload generated patch
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: protobuf-sources-patch
path: /tmp/protobuf-sources.patch
retention-days: 5
publish:
runs-on: ubuntu-24.04
needs: generate
permissions:
contents: write # push regenerated sources back to the renovate branch
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
with:
ref: ${{ github.ref }}
# zizmor: ignore[artipacked] -- needs credentials to push
persist-credentials: true
- name: Download generated patch
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: protobuf-sources-patch
path: /tmp/patch
- name: Commit and push generated sources
run: |
PATCH=/tmp/patch/protobuf-sources.patch
if [[ ! -s "$PATCH" ]]; then
echo "No generated changes to commit"
exit 0
fi
git apply "$PATCH"
# Note: GITHUB_TOKEN pushes don't trigger CI re-runs.
# Close and reopen the PR to trigger CI after this commit.
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add '*.java'
git commit -m "chore: regenerate protobuf sources"
git push