Skip to content

Commit 8c99d6d

Browse files
committed
ci: use underscores for script name and restore fallback checks
1 parent a8a9233 commit 8c99d6d

2 files changed

Lines changed: 33 additions & 23 deletions

File tree

.github/scripts/verify-showcase-version.go renamed to .github/scripts/verify_showcase_version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func main() {
6262

6363
if *showcaseCommit != expectedCommit {
6464
fmt.Fprintf(os.Stderr, "Mismatch: librarian.yaml has commit %q, but tag %q is at commit %q\n", *showcaseCommit, tagName, expectedCommit)
65-
os.Exit(1)
65+
os.Exit(2)
6666
}
6767

6868
fmt.Println("Showcase version and commit are in sync!")

.github/workflows/showcase-version-check.yaml

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ on:
2323
- 'librarian.yaml'
2424
- 'java-showcase/gapic-showcase/pom.xml'
2525
- '.github/workflows/showcase-version-check.yaml'
26-
- '.github/scripts/verify-showcase-version.go'
26+
- '.github/scripts/verify_showcase_version.go'
2727

2828
jobs:
2929
check-version:
@@ -32,50 +32,60 @@ jobs:
3232
issues: write
3333
steps:
3434
- uses: actions/checkout@v4
35-
3635
- name: Extract showcase version from pom.xml
3736
id: extract_version
3837
shell: bash
3938
run: |
4039
version=$(mvn help:evaluate -f java-showcase/gapic-showcase/pom.xml -Dexpression=gapic-showcase.version -q -DforceStdout 2>/dev/null || true)
41-
if [ -z "$version" ]; then
42-
echo "Warning: Maven evaluation failed. Falling back to XML parsing of pom.xml..."
43-
version=$(grep -oE '<gapic-showcase\.version>[0-9]+\.[0-9]+\.[0-9]+</gapic-showcase\.version>' java-showcase/gapic-showcase/pom.xml | sed -E 's/<[^>]+>//g')
44-
fi
45-
if [ -z "$version" ]; then
46-
echo "Error: Could not find gapic-showcase.version in pom.xml"
47-
exit 1
48-
fi
4940
echo "version=$version" >> "$GITHUB_OUTPUT"
50-
5141
- name: Extract showcase commit from librarian.yaml
5242
id: extract_commit
5343
shell: bash
5444
run: |
5545
commit=$(grep -A 1 "showcase:" librarian.yaml | grep "commit:" | awk '{print $2}')
56-
if [ -z "$commit" ]; then
57-
echo "Error: Could not find showcase commit in librarian.yaml"
58-
exit 1
59-
fi
6046
echo "commit=$commit" >> "$GITHUB_OUTPUT"
61-
6247
- name: Set up Go
6348
uses: actions/setup-go@v5
6449
with:
6550
go-version: '1.24'
66-
6751
- name: Verify showcase version and commit match
52+
shell: bash
6853
run: |
69-
go run .github/scripts/verify-showcase-version.go \
54+
set +e
55+
go run .github/scripts/verify_showcase_version.go \
7056
-version "${{ steps.extract_version.outputs.version }}" \
7157
-commit "${{ steps.extract_commit.outputs.commit }}"
58+
exit_code=$?
59+
set -e
60+
61+
if [ $exit_code -eq 0 ]; then
62+
echo "Verification successful!"
63+
exit 0
64+
elif [ $exit_code -eq 2 ]; then
65+
echo "MISMATCH=true" >> "$GITHUB_ENV"
66+
echo "Error: Showcase version mismatch detected."
67+
exit 2
68+
else
69+
echo "Error: Unexpected verification failure (exit code $exit_code)."
70+
exit 1
71+
fi
72+
73+
- name: Create issue on mismatch
74+
if: failure() && env.MISMATCH == 'true'
75+
env:
76+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
run: |
78+
gh issue create \
79+
-R "${{ github.repository }}" \
80+
-t "Showcase Version Mismatch: librarian.yaml and pom.xml out of sync" \
81+
-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 }}"
7282
73-
- name: Create issue on failure
74-
if: failure()
83+
- name: Create issue on workflow failure
84+
if: failure() && env.MISMATCH != 'true'
7585
env:
7686
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7787
run: |
7888
gh issue create \
7989
-R "${{ github.repository }}" \
80-
-t "Showcase Version Check Failure" \
81-
-b "The Showcase Version Check workflow has failed. Please check the logs at ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} for details."
90+
-t "Showcase Version Check Workflow Failure" \
91+
-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."

0 commit comments

Comments
 (0)