-
Notifications
You must be signed in to change notification settings - Fork 1.1k
88 lines (85 loc) · 3.47 KB
/
Copy pathshowcase-version-check.yaml
File metadata and controls
88 lines (85 loc) · 3.47 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
# Copyright 2026 Google LLC
#
# Licensed 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
#
# https://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: Showcase Version Check
on:
schedule:
- cron: '30 3 * * *' # Run daily at 3:30 AM UTC
workflow_dispatch: # Allow manual trigger
pull_request:
paths:
- 'librarian.yaml'
- 'java-showcase/gapic-showcase/pom.xml'
- '.github/workflows/showcase-version-check.yaml'
- '.github/scripts/verify_showcase_version.go'
jobs:
check-version:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/checkout@v4
- name: Extract showcase version from pom.xml
id: extract_version
shell: bash
run: |
version=$(awk -F'[<>]' '/gapic-showcase.version/{print $3; exit}' java-showcase/gapic-showcase/pom.xml)
echo "version=$version" >> "$GITHUB_OUTPUT"
- name: Extract showcase commit from librarian.yaml
id: extract_commit
shell: bash
run: |
commit=$(grep -A 1 "showcase:" librarian.yaml | grep "commit:" | awk '{print $2}')
echo "commit=$commit" >> "$GITHUB_OUTPUT"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Verify showcase version and commit match
shell: bash
run: |
set +e
go run .github/scripts/verify_showcase_version.go \
-version "${{ steps.extract_version.outputs.version }}" \
-commit "${{ steps.extract_commit.outputs.commit }}"
exit_code=$?
set -e
if [ $exit_code -eq 0 ]; then
echo "Verification successful!"
exit 0
elif [ $exit_code -eq 2 ]; then
echo "MISMATCH=true" >> "$GITHUB_ENV"
echo "Error: Showcase version mismatch detected."
exit 2
else
echo "Error: Unexpected verification failure (exit code $exit_code)."
exit 1
fi
- name: Create issue on mismatch
if: failure() && env.MISMATCH == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue create \
-R "${{ github.repository }}" \
-t "Showcase Version Mismatch: librarian.yaml and pom.xml out of sync" \
-b "The Showcase version in java-showcase/gapic-showcase/pom.xml and the commit in librarian.yaml do not match. Please update them to match. See logs: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
- name: Create issue on workflow failure
if: failure() && env.MISMATCH != 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh issue create \
-R "${{ github.repository }}" \
-t "Showcase Version Check Workflow Failure" \
-b "The Showcase Version Check workflow has failed due to an unexpected execution error. Please check the logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details."