ci: fix version extraction regex in verify-version - #375
Conversation
The verify-version job extracted the version with: grep -oP "'\K[^']+" This pattern has no closing-quote requirement, so on a line like version = '0.9.10' // x-release-please-version it matched twice: once for `0.9.10` and again for the text following the second quote (` // x-release-please-version`). Command substitution joined both matches with a newline, so GRADLE_VERSION/PUBLISH_VERSION became two-line strings that could never compare equal to the manifest version, failing every tagged release. Add a `(?=')` lookahead so the match must terminate at a closing quote, which keeps the marker comment from being captured. This matches the idiom already used correctly in openfga/go-sdk. Verified against GNU grep on ubuntu:24.04 (the runner image); the check still fails correctly when versions genuinely diverge.
📄 Knowledge reviewDosu skipped reviewing this PR because your organization has used its |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughThe workflow updates Gradle and publish version extraction. Regex lookaheads now require a closing quote, which excludes trailing release marker comments from captured versions. ChangesVersion parsing workflow
Estimated code review effort: 1 (Trivial) | ~2 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟢 Ready to approve
The regex change directly addresses the documented failure mode and is consistent with the tagged-version validation logic in the workflow.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Fixes the verify-version GitHub Actions job so it correctly extracts the Gradle version when the // x-release-please-version marker comment is present, preventing false mismatches on tagged releases.
Changes:
- Tighten the PCRE extraction regex by requiring a closing quote via a
(?=')lookahead. - Add an inline comment explaining why the lookahead is necessary to avoid a second match.
File summaries
| File | Description |
|---|---|
| .github/workflows/main.yaml | Updates version extraction in verify-version to avoid capturing the marker comment as a second match. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #375 +/- ##
============================================
- Coverage 38.69% 38.67% -0.02%
+ Complexity 1289 1288 -1
============================================
Files 198 198
Lines 7707 7707
Branches 900 900
============================================
- Hits 2982 2981 -1
Misses 4579 4579
- Partials 146 147 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Problem
The
verify-versionjob fails on every tagged release. It blocked thev0.9.10release: run 30894824034.The job logs show the version being printed across two lines:
Root cause
The extraction used:
grep -oP "'\K[^']+"[^']+has no closing-quote requirement, so on a line likeit matched twice — once for
0.9.10, and again for everything after the second quote (// x-release-please-version). Command substitution joined both matches with a newline, so$GRADLE_VERSIONbecame a two-line string that could never compare equal to0.9.10.Fix
Add a
(?=')lookahead so the match must terminate at a closing quote. The marker comment is no longer captured. This is the same idiom already used correctly in openfga/go-sdk.Notes
v0.9.9was tagged, sov0.9.10was the first tag to ever reach it — it has never passed.0.9.10, GitHub Packages never ran, and the GitHub release is still a draft. Nothing was partially published.dotnet-sdkuses a similar pattern but is not affected (its marker is<!-- ... -->, and[^<]+cannot match across the newline).go-sdkis already correct.Testing
Verified against GNU grep on
ubuntu:24.04(the runner image), since macOS/BSD grep lacks-P:Also confirmed the check still fails correctly when a version genuinely diverges, so the guardrail is preserved rather than weakened.
Follow-up
v0.9.10cannot be recovered by re-running the failed job: a tag-push run executes the workflow file from the tag's own tree, which still contains the buggy line. The tag rulesets (Restrict Tag Deletions,Enforce Tag Creation) are active with no bypass actors, so the tag cannot be moved either. Once this merges, the release will be re-cut as0.9.11and the stalev0.9.10draft release cleaned up.Summary by CodeRabbit