Skip to content

ci: fix version extraction regex in verify-version - #375

Merged
SoulPancake merged 1 commit into
mainfrom
ci/fix-verify-version-regex
Aug 4, 2026
Merged

ci: fix version extraction regex in verify-version#375
SoulPancake merged 1 commit into
mainfrom
ci/fix-verify-version-regex

Conversation

@SoulPancake

@SoulPancake SoulPancake commented Aug 4, 2026

Copy link
Copy Markdown
Member

Problem

The verify-version job fails on every tagged release. It blocked the v0.9.10 release: run 30894824034.

The job logs show the version being printed across two lines:

Tag: 0.9.10 | Manifest: 0.9.10 | build.gradle: 0.9.10
 // x-release-please-version | publish.gradle: 0.9.10
 // x-release-please-version
ERROR: build.gradle version does not match manifest version

Root cause

The extraction used:

grep -oP "'\K[^']+"

[^']+ 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 everything after the second quote ( // x-release-please-version). Command substitution joined both matches with a newline, so $GRADLE_VERSION became a two-line string that could never compare equal to 0.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

  • This check was added in 8c36b13, after v0.9.9 was tagged, so v0.9.10 was the first tag to ever reach it — it has never passed.
  • The pipeline failed closed, before any publish step. Maven Central has no 0.9.10, GitHub Packages never ran, and the GitHub release is still a draft. Nothing was partially published.
  • dotnet-sdk uses a similar pattern but is not affected (its marker is <!-- ... -->, and [^<]+ cannot match across the newline). go-sdk is already correct.

Testing

Verified against GNU grep on ubuntu:24.04 (the runner image), since macOS/BSD grep lacks -P:

Tag: 0.9.10 | Manifest: 0.9.10 | build.gradle: 0.9.10 | publish.gradle: 0.9.10
All versions verified: 0.9.10

Also confirmed the check still fails correctly when a version genuinely diverges, so the guardrail is preserved rather than weakened.

Follow-up

v0.9.10 cannot 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 as 0.9.11 and the stale v0.9.10 draft release cleaned up.

Summary by CodeRabbit

  • Bug Fixes
    • Improved version detection during builds and publishing to prevent trailing release comments from being included in version numbers.

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.
@SoulPancake
SoulPancake requested a review from a team as a code owner August 4, 2026 09:58
Copilot AI lite review requested due to automatic review settings August 4, 2026 09:58
@dosubot

dosubot Bot commented Aug 4, 2026

Copy link
Copy Markdown

📄 Knowledge review

Dosu skipped reviewing this PR because your organization has used its 200 included credits for the month. Your usage will reset on 2026-09-01. To have Dosu review this PR before then, ask your organization admin to upgrade to a pro account.


Leave Feedback Ask Dosu about java-sdk Add Dosu to your team

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a6b1c307-45f5-405b-a6df-c38a52615829

📥 Commits

Reviewing files that changed from the base of the PR and between a659c1a and 68a5bdc.

📒 Files selected for processing (1)
  • .github/workflows/main.yaml

Walkthrough

The workflow updates Gradle and publish version extraction. Regex lookaheads now require a closing quote, which excludes trailing release marker comments from captured versions.

Changes

Version parsing workflow

Layer / File(s) Summary
Quoted version extraction
.github/workflows/main.yaml
The Gradle and publish version regex patterns now capture only quoted version values and exclude trailing marker comments.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: aaguiarz

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the CI regex fix for version extraction in the verify-version job.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/fix-verify-version-regex

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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-commenter

codecov-commenter commented Aug 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.67%. Comparing base (a659c1a) to head (68a5bdc).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SoulPancake
SoulPancake added this pull request to the merge queue Aug 4, 2026
Merged via the queue into main with commit e687519 Aug 4, 2026
30 checks passed
@SoulPancake
SoulPancake deleted the ci/fix-verify-version-regex branch August 4, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants