Skip to content

Commit 9603796

Browse files
authored
chore: add generation step for commit (#13337)
Adds a step to generate libraries when changing a librarian.yaml workflow [Fixes #6219](googleapis/librarian#6219)
1 parent c0405d0 commit 9603796

1 file changed

Lines changed: 46 additions & 3 deletions

File tree

.github/workflows/update_librarian_googleapis.yaml

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ jobs:
6868
new_commit=$(go run "github.com/googleapis/librarian/cmd/librarian@${version}" config get sources.googleapis.commit)
6969
echo "new_commit=${new_commit}" >> $GITHUB_OUTPUT
7070
echo "short_commit=${new_commit:0:7}" >> $GITHUB_OUTPUT
71-
- name: Detect Changes
72-
id: detect
71+
- name: Detect Changes To Librarian.yaml
72+
id: detect_librarian
7373
run: |
7474
git add librarian.yaml
7575
changed_files=$(git diff --cached --name-only)
@@ -79,8 +79,51 @@ jobs:
7979
else
8080
echo "has_changes=true" >> $GITHUB_OUTPUT
8181
fi
82+
- name: Install protoc
83+
run: |
84+
set -e
85+
VERSION="33.2"
86+
curl -fsSL --retry 5 --retry-delay 15 -o /tmp/protoc.zip "https://github.com/protocolbuffers/protobuf/releases/download/v$VERSION/protoc-$VERSION-linux-x86_64.zip"
87+
cd /usr/local
88+
sudo unzip -o /tmp/protoc.zip
89+
protoc --version
90+
- uses: actions/setup-java@v4
91+
with:
92+
java-version: "17"
93+
distribution: "temurin"
94+
cache: "maven"
95+
- name: Verify Java and Maven installation
96+
run: |
97+
java -version
98+
if ! command -v mvn &> /dev/null; then
99+
sudo apt-get update && sudo apt-get install -y maven
100+
fi
101+
mvn -version
102+
- uses: actions/setup-python@v5
103+
with:
104+
python-version: "3.12"
105+
cache: 'pip'
106+
- name: Run librarian install
107+
run: |
108+
go run github.com/googleapis/librarian/cmd/librarian@latest install
109+
echo "$HOME/java_tools/bin" >> $GITHUB_PATH
110+
env:
111+
PYTHONPATH: ${{ github.workspace }}/sdk-platform-java/hermetic_build/library_generation/owlbot
112+
- name: Generate Libraries
113+
if: steps.detect_librarian.outputs.has_changes == 'true'
114+
id: generate
115+
run: |
116+
go run github.com/googleapis/librarian/cmd/librarian@latest generate --all
117+
git add .
118+
changed_files=$(git diff --cached --name-only)
119+
if [[ "${changed_files}" == "" ]]; then
120+
echo "has_changes=false" >> $GITHUB_OUTPUT
121+
echo "No changes in libraries"
122+
else
123+
echo "has_changes=true" >> $GITHUB_OUTPUT
124+
fi
82125
- name: Commit and Create PR
83-
if: steps.detect.outputs.has_changes == 'true'
126+
if: steps.detect_librarian.outputs.has_changes == 'true' || steps.generate.outputs.has_changes == 'true'
84127
env:
85128
GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }}
86129
PR_TITLE: "chore: update googleapis commitish to ${{ steps.commit.outputs.short_commit }}"

0 commit comments

Comments
 (0)