Skip to content

build: use PROJECT_VERSION as single source of truth#27

Merged
rophy merged 4 commits into
masterfrom
build/version-from-cmake
Jul 5, 2026
Merged

build: use PROJECT_VERSION as single source of truth#27
rophy merged 4 commits into
masterfrom
build/version-from-cmake

Conversation

@rophy

@rophy rophy commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace git describe --tags with PROJECT_VERSION from CMakeLists.txt as the version source
  • Git short SHA appended as build metadata (e.g. 1.9.0.2-1b09ac55)
  • Release workflow triggers on CMakeLists.txt changes to master, not tag push
  • Skip build if GHCR image already exists for that version
  • Bump version to 1.9.0.2

Files changed

  • CMakeLists.txt — version bump + git SHA logic
  • Makefile — pass GIT_SHORT_SHA instead of OLR_VERSION
  • Dockerfile.dev / Dockerfile.releaseARG GIT_SHORT_SHA replaces ARG OLR_VERSION
  • .github/workflows/release.yaml — trigger on cmake change, extract version, skip if exists

Test plan

  • Local build: make build → version shows 1.9.0.2-1b09ac55
  • Redo regression: 161/161 passed (on prior commit, same OLR code)

Summary by CodeRabbit

  • New Features

    • Release builds now use the project version for image tags, with optional short commit information included in build metadata.
  • Bug Fixes

    • Avoids rebuilding and republishing a release image when the same tag already exists.
    • Release automation now follows version updates more reliably, reducing accidental duplicate releases.

rophy added 3 commits July 3, 2026 06:59
Replace git describe --tags with PROJECT_VERSION from CMakeLists.txt.
Git short SHA appended as build metadata (e.g. 1.9.0.2-1b09ac55).
Trigger on CMakeLists.txt changes to master instead of tag push.
Extract version from PROJECT_VERSION, skip build if image exists.
@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@rophy, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0a624d77-b132-43e4-b3c8-8d3dd4ff3ab4

📥 Commits

Reviewing files that changed from the base of the PR and between 7f6c618 and ad3938d.

📒 Files selected for processing (2)
  • .github/workflows/release.yaml
  • Dockerfile.release
📝 Walkthrough

Walkthrough

The release process is reworked to derive the version from CMakeLists.txt instead of git tags/describe, introducing a separate GIT_SHORT_SHA build argument. The release workflow now triggers on master pushes touching CMakeLists.txt, checks for existing image tags before rebuilding, and Dockerfiles/Makefile propagate GIT_SHORT_SHA instead of OLR_VERSION.

Changes

Version and build-arg rework

Layer / File(s) Summary
CMake version and GIT_SHORT_SHA derivation
CMakeLists.txt
Project version bumped to 1.9.0.3; OLR_VERSION now defaults to PROJECT_VERSION with an optional git short-SHA suffix from git rev-parse --short HEAD, replacing the previous git describe-based logic.
Dockerfile build-arg rename
Dockerfile.dev, Dockerfile.release
Both Dockerfiles replace the OLR_VERSION build argument with GIT_SHORT_SHA and update the conditional CMake -D flag passed during configure.
Makefile build-arg and release tag wiring
Makefile
Adds a GIT_SHORT_SHA variable from git rev-parse --short HEAD, passes it as a build-arg in the build and build-release targets, and derives the build-release image tag from the version parsed out of CMakeLists.txt.
Release workflow trigger and idempotent publish logic
.github/workflows/release.yaml
Trigger changes from tag pushes to master branch pushes scoped to CMakeLists.txt changes; the job extracts the version, checks for an existing ghcr.io image tag via docker manifest inspect, and conditionally skips or performs build/login/push with GIT_SHORT_SHA as a build arg.

Estimated code review effort: 2 (Simple) | ~12 minutes

Sequence Diagram(s)

sequenceDiagram
  participant GitHub as GitHub Actions
  participant CMakeLists as CMakeLists.txt
  participant Registry as ghcr.io

  GitHub->>CMakeLists: extract VERSION
  GitHub->>Registry: docker manifest inspect image:VERSION
  alt tag exists
    Registry-->>GitHub: manifest found
    GitHub->>GitHub: skip build/push
  else tag missing
    Registry-->>GitHub: manifest not found
    GitHub->>GitHub: buildx setup + login
    GitHub->>Registry: build and push image:VERSION with GIT_SHORT_SHA
  end
Loading

Possibly related PRs

  • rophy/OpenLogReplicator#21: Originally introduced the OLR_VERSION/git describe-based versioning plumbing through CMake/Docker/Make that this PR replaces.
  • rophy/OpenLogReplicator#23: Added the tag-triggered release workflow and Dockerfile.release build using OLR_VERSION that this PR modifies.
🚥 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 matches the main change: switching build versioning to PROJECT_VERSION as the source of truth.
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 build/version-from-cmake

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.

@rophy

rophy commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
Dockerfile.release (1)

8-14: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Update stale usage example — still references removed OLR_VERSION build-arg.

The header comment still shows OLR_VERSION=$(git describe --tags --always --dirty) and --build-arg OLR_VERSION=$OLR_VERSION, but the builder stage now takes GIT_SHORT_SHA (line 26) instead. Following this example verbatim would silently no-op the version override.

📝 Proposed fix
-#   OLR_VERSION=$(git describe --tags --always --dirty)
+#   GIT_SHORT_SHA=$(git rev-parse --short HEAD)
 #   docker buildx build -f Dockerfile.release \
-#     --build-arg OLR_VERSION=$OLR_VERSION \
+#     --build-arg GIT_SHORT_SHA=$GIT_SHORT_SHA \
 #     --build-arg GIDOLR=$(id -g) --build-arg UIDOLR=$(id -u) \
 #     --build-arg WITHORACLE=1 --build-arg WITHKAFKA=1 \
 #     --build-arg WITHPROTOBUF=1 --build-arg WITHPROMETHEUS=1 \
-#     -t rophy/openlogreplicator:$OLR_VERSION .
+#     -t rophy/openlogreplicator:$GIT_SHORT_SHA .
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Dockerfile.release` around lines 8 - 14, The usage example in
Dockerfile.release is stale because it still documents the removed OLR_VERSION
build arg. Update the example to match the current builder inputs by referencing
GIT_SHORT_SHA instead, and make sure the sample build command uses the same
version source expected by the Dockerfile so readers do not follow an argument
that is ignored. Use the existing Dockerfile.release build-arg example block as
the location to revise.
🧹 Nitpick comments (2)
.github/workflows/release.yaml (1)

27-35: 🔒 Security & Privacy | 🔵 Trivial | ⚡ Quick win

Prefer env: binding over inline template expansion in run: scripts.

Static analysis flags potential template-injection risk from interpolating ${{ steps.version.outputs.version }} directly into the shell script. Even though the value here is derived from trusted repo content, the safer idiom is to bind it to an environment variable and reference it as a shell variable.

🛡️ Proposed fix
       - name: Check if image already exists
         id: check
         run: |
-          if docker manifest inspect "${{ env.IMAGE }}:${{ steps.version.outputs.version }}" > /dev/null 2>&1; then
+          if docker manifest inspect "${IMAGE}:${VERSION}" > /dev/null 2>&1; then
             echo "exists=true" >> "$GITHUB_OUTPUT"
-            echo "Image ${{ env.IMAGE }}:${{ steps.version.outputs.version }} already exists, skipping build"
+            echo "Image ${IMAGE}:${VERSION} already exists, skipping build"
           else
             echo "exists=false" >> "$GITHUB_OUTPUT"
           fi
         env:
           DOCKER_CLI_EXPERIMENTAL: enabled
+          VERSION: ${{ steps.version.outputs.version }}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/release.yaml around lines 27 - 35, Bind the image version
used in the “Check if image already exists” step to an env variable instead of
interpolating steps.version.outputs.version directly inside the run script.
Update the step that uses docker manifest inspect and the echo output to
reference a shell variable populated from env:, so the shell script no longer
contains inline template expansion. Keep the existing behavior and output, just
move the version value into the step’s environment.

Source: Linters/SAST tools

Makefile (1)

38-38: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated version-extraction regex between Makefile and release.yaml.

The grep -oP 'VERSION \K[0-9]+(\.[0-9]+)+' CMakeLists.txt | head -1 logic is duplicated verbatim in .github/workflows/release.yaml (line 23). If the CMakeLists.txt format changes, both call sites must be updated in lockstep, or the two version sources will drift.

Consider extracting into a small shared script (e.g. scripts/get_version.sh) invoked from both places.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Makefile` at line 38, The version-extraction logic is duplicated between the
Makefile and the release workflow, so update the Makefile’s image tag generation
to delegate to a shared helper instead of embedding the regex directly. Add a
small reusable version script (for example, a script invoked by the Makefile
target and by the release workflow) and have both call that shared entry point
so the CMakeLists.txt parsing lives in one place. Reference the existing
Makefile tag rule and the release workflow’s version lookup so the
implementation stays consistent across both call sites.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/release.yaml:
- Around line 50-59: The release workflow is passing the full commit hash into
GIT_SHORT_SHA, which breaks the intended short-SHA version format. Update the
Build and push release image step in the release workflow to use a truncated SHA
instead of github.sha directly, preferably by adding a prior short_sha step and
wiring its output into the build-args. Make sure the value passed to Docker
matches the GIT_SHORT_SHA contract used by CMakeLists.txt and the version
tagging logic.

---

Outside diff comments:
In `@Dockerfile.release`:
- Around line 8-14: The usage example in Dockerfile.release is stale because it
still documents the removed OLR_VERSION build arg. Update the example to match
the current builder inputs by referencing GIT_SHORT_SHA instead, and make sure
the sample build command uses the same version source expected by the Dockerfile
so readers do not follow an argument that is ignored. Use the existing
Dockerfile.release build-arg example block as the location to revise.

---

Nitpick comments:
In @.github/workflows/release.yaml:
- Around line 27-35: Bind the image version used in the “Check if image already
exists” step to an env variable instead of interpolating
steps.version.outputs.version directly inside the run script. Update the step
that uses docker manifest inspect and the echo output to reference a shell
variable populated from env:, so the shell script no longer contains inline
template expansion. Keep the existing behavior and output, just move the version
value into the step’s environment.

In `@Makefile`:
- Line 38: The version-extraction logic is duplicated between the Makefile and
the release workflow, so update the Makefile’s image tag generation to delegate
to a shared helper instead of embedding the regex directly. Add a small reusable
version script (for example, a script invoked by the Makefile target and by the
release workflow) and have both call that shared entry point so the
CMakeLists.txt parsing lives in one place. Reference the existing Makefile tag
rule and the release workflow’s version lookup so the implementation stays
consistent across both call sites.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 41fcb6ce-0c60-408a-ba34-399e803d568a

📥 Commits

Reviewing files that changed from the base of the PR and between 1b09ac5 and 7f6c618.

📒 Files selected for processing (5)
  • .github/workflows/release.yaml
  • CMakeLists.txt
  • Dockerfile.dev
  • Dockerfile.release
  • Makefile

Comment thread .github/workflows/release.yaml Outdated
- Truncate github.sha to 8 chars for GIT_SHORT_SHA
- Use env binding instead of inline template in shell scripts
- Update stale usage comment in Dockerfile.release
@rophy

rophy commented Jul 5, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rophy rophy merged commit a6a12f9 into master Jul 5, 2026
1 of 2 checks passed
@rophy rophy deleted the build/version-from-cmake branch July 5, 2026 19:36
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.

1 participant