-
Notifications
You must be signed in to change notification settings - Fork 4.6k
add upgrade gcp bom workflow #38711
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
derrickaw
wants to merge
7
commits into
master
Choose a base branch
from
20260527_createBOMWorkflow
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−0
Open
add upgrade gcp bom workflow #38711
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2cb5880
initial draft bom workflow
derrickaw d2a56a5
add temp fix
derrickaw 8ff89af
Document new GCP BOM upgrade workflow in README
derrickaw 30a8343
Fix YAML indentation for push branches trigger
derrickaw 2d9e874
remove tmp push
derrickaw d2cdedf
Rename workflow to Upgrade GCP Libraries BOM
derrickaw e490f90
fix gemini comments
derrickaw File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You 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: Upgrade GCP Libraries BOM | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "0 0 * * 0" # Weekly on Sundays at 00:00 UTC | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
| checks: read | ||
| issues: read | ||
| statuses: read | ||
|
|
||
| concurrency: | ||
| group: '${{ github.workflow }} @ ${{ github.ref }}' | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| upgrade_gcp_bom: | ||
| runs-on: [self-hosted, ubuntu-24.04, main] | ||
| name: Upgrade GCP BOM | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v6 | ||
| - name: Setup environment | ||
| uses: ./.github/actions/setup-environment-action | ||
| with: | ||
| python-version: 3.11 | ||
| java-version: default | ||
| go-version: default | ||
| - name: Check if new BOM is available | ||
| id: check_bom | ||
| run: python3 scripts/tools/gcp_bom_upgrade_check.py | ||
| - name: Run bomupgrader | ||
| if: steps.check_bom.outputs.should_upgrade == 'true' | ||
| run: python3 scripts/tools/bomupgrader.py ${{ steps.check_bom.outputs.latest_version }} | ||
| - name: Install gh cli | ||
| if: steps.check_bom.outputs.should_upgrade == 'true' | ||
| uses: ./.github/actions/setup-gh-cli-linux | ||
| - name: Set git config | ||
| if: steps.check_bom.outputs.should_upgrade == 'true' | ||
| run: | | ||
| git config user.name $GITHUB_ACTOR | ||
| git config user.email actions@"$RUNNER_NAME".local | ||
| - name: Commit Changes and create PR | ||
| if: steps.check_bom.outputs.should_upgrade == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| LATEST_VER: ${{ steps.check_bom.outputs.latest_version }} | ||
| CURRENT_VER: ${{ steps.check_bom.outputs.current_version }} | ||
| run: | | ||
| branchName=upgrade_gcp_bom_${LATEST_VER//./_} | ||
| git checkout -b $branchName | ||
| git add -A | ||
| git diff-index --quiet HEAD || gitdiff=$? || echo $? | ||
| if [[ $gitDiff != 0 ]]; then | ||
| echo "Changes are ready to commit" | ||
| git commit -m "Upgrade GCP Libraries BOM to ${LATEST_VER}" --quiet | ||
| git push origin $branchName --quiet | ||
|
|
||
| PR_BODY="This PR was created by automation. It upgrades the Google Cloud Platform Libraries BOM from **${CURRENT_VER}** to **${LATEST_VER}** and updates Netty, gRPC, Arrow, Gax, Protobuf, and OpenTelemetry versions to match. | ||
|
|
||
| Please review the changes and merge if all tests pass." | ||
|
|
||
| GITHUB_PR_URL=$(gh pr create --title "Upgrade GCP Libraries BOM to ${LATEST_VER}" --body "$PR_BODY" --label "dependencies" --base master) | ||
| echo "Link of the new PR: $GITHUB_PR_URL" | ||
| else | ||
| echo "No changes on the files" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to You 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. | ||
|
|
||
| import urllib.request | ||
| import re | ||
| import os | ||
|
|
||
| def get_latest_bom(): | ||
| url = "https://repo1.maven.org/maven2/com/google/cloud/libraries-bom/maven-metadata.xml" | ||
| with urllib.request.urlopen(url, timeout=15) as response: | ||
| xml = response.read().decode('utf-8') | ||
| match = re.search(r'<release>([^<]+)</release>', xml) | ||
| if match: | ||
| return match.group(1) | ||
| raise RuntimeError("Could not find latest release in Maven metadata") | ||
|
|
||
| def get_current_bom(): | ||
| path = "buildSrc/src/main/groovy/org/apache/beam/gradle/BeamModulePlugin.groovy" | ||
| with open(path) as f: | ||
| content = f.read() | ||
|
derrickaw marked this conversation as resolved.
|
||
| match = re.search(r'google_cloud_platform_libraries_bom\s*:\s*[\"\']com\.google\.cloud:libraries-bom:([0-9.]+)[\"\']', content) | ||
| if match: | ||
| return match.group(1) | ||
| raise RuntimeError("Could not find current libraries-bom in BeamModulePlugin.groovy") | ||
|
|
||
| def to_tuple(version_str): | ||
| parts = [] | ||
| for part in version_str.split('.'): | ||
| match = re.match(r'^(\d+)', part) | ||
| parts.append(int(match.group(1)) if match else 0) | ||
| return tuple(parts) | ||
|
|
||
| def main(): | ||
| latest = get_latest_bom() | ||
| current = get_current_bom() | ||
| print(f"Latest libraries-bom version: {latest}") | ||
| print(f"Current libraries-bom version: {current}") | ||
|
|
||
| should_upgrade = to_tuple(latest) > to_tuple(current) | ||
|
|
||
| github_output = os.getenv('GITHUB_OUTPUT') | ||
| if github_output: | ||
| with open(github_output, 'a') as f: | ||
| f.write(f"should_upgrade={str(should_upgrade).lower()}\n") | ||
| f.write(f"latest_version={latest}\n") | ||
| f.write(f"current_version={current}\n") | ||
|
|
||
| if should_upgrade: | ||
| print("A newer version of libraries-bom is available. Upgrade needed.") | ||
| else: | ||
| print("libraries-bom is up-to-date.") | ||
|
|
||
| if __name__ == '__main__': | ||
| main() | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.