Skip to content

Add -v/--version flag, derived from the git tag#12

Merged
tyom merged 1 commit into
mainfrom
versioning
May 23, 2026
Merged

Add -v/--version flag, derived from the git tag#12
tyom merged 1 commit into
mainfrom
versioning

Conversation

@tyom
Copy link
Copy Markdown
Owner

@tyom tyom commented May 23, 2026

What

Adds -v / --version to print the tool version, with the git tag as the single source of truth — no hardcoded constant to bump.

$ repo-intel --version
repo-intel 1.2.0

How the version resolves

Context Source Reports
Released binary (install.sh, curl pipe, Homebrew) tag baked in at release-build via $REPO_INTEL_VERSION repo-intel 1.2.0
Raw source checkout (make dev) git describe in the script's own dir repo-intel v1.2.0-3-gabc
Committed dist/repo-intel 0.0.0-dev sentinel dev version

All user-facing install paths fetch the same released asset, so all three report the baked version (verified for each).

Why the committed artifact can't carry a real number

CI's stale-artifact gate requires make build to be byte-for-byte reproducible at every commit. A git describe value changes between commits, which would fail that gate. So the version is injected only at release-build time (via env var): the committed artifact stays reproducible while the released asset carries the real tag. No drift gate needed — there's no constant to keep in sync.

Changes

  • repo-intel.pyVERSION sentinel, resolve_version() (describes its own dir, not the analyzed repo's cwd), -v/--version short-circuit in parse_args, HELP text.
  • build.py — bakes $REPO_INTEL_VERSION into the artifact when set; leaves the sentinel otherwise.
  • release.yml — passes the tag to the build step; published-artifact smoke test now asserts repo-intel <version>.
  • dist/repo-intel — rebuilt (verified byte-identical across consecutive builds).
  • README.md — notes --version.

Verification

  • Source / sentinel / baked resolution paths all work; reproducible rebuild (matching SHA).
  • make check passes (Ruff lint+format, Prettier, svelte-check).
  • Prerelease tags (1.2.3-rc1) flow through correctly.
  • All three install paths (install.sh, curl | python3 -, Homebrew) report the baked version.

Summary by CodeRabbit

  • New Features

    • Added -v/--version flag to display the tool version
    • Version is now embedded in released binaries with automated verification
  • Documentation

    • Updated README to document the new version flag

Review Change Stack

The git tag stays the single source of truth (the release flow is already
tag-driven). build.py bakes $REPO_INTEL_VERSION into the released artifact;
a raw source checkout derives from `git describe` against the script's own
directory. The committed dist/repo-intel keeps a 0.0.0-dev sentinel so
`make build` stays byte-for-byte reproducible (CI gates that), while the
released asset carries the real tag. release.yml passes the tag to the build
and the published-artifact smoke test asserts the baked version.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 03c3c9eb-e73b-4825-a291-ae20609dd8cb

📥 Commits

Reviewing files that changed from the base of the PR and between 71cc54e and e82db99.

⛔ Files ignored due to path filters (1)
  • dist/repo-intel is excluded by !**/dist/**
📒 Files selected for processing (4)
  • .github/workflows/release.yml
  • README.md
  • build.py
  • repo-intel.py

📝 Walkthrough

Walkthrough

The PR implements a complete versioning system: repo-intel now accepts -v/--version to report its version, the build process embeds the release tag into the binary via placeholder substitution, the release workflow validates the embedded version matches the tag, and documentation guides users on the new flag.

Changes

Versioning Feature

Layer / File(s) Summary
Version CLI implementation
repo-intel.py
Introduces VERSION sentinel constant, resolve_version() function that reads either the baked-in tag or resolves via git describe, updates help text to document -v/--version, and integrates argument parsing to print the resolved version and exit.
Build-time version embedding
build.py
Defines VERSION_PLACEHOLDER sentinel and adds logic to read REPO_INTEL_VERSION from environment, verify the placeholder appears exactly once in bundled output, and conditionally replace it with the actual version; preserves byte-for-byte determinism when no version is provided.
Release pipeline integration
.github/workflows/release.yml
Passes the resolved git tag as REPO_INTEL_VERSION to the build step and strengthens the smoke test to verify repo-intel --version matches the tag (with leading v stripped), failing the workflow with an explicit error on mismatch.
User documentation
README.md
Documents that repo-intel --version or repo-intel -v prints the tool version.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • tyom/repo-intel#8: Both PRs modify the GitHub Actions release pipeline in .github/workflows/release.yml, specifically how the effective release tag is derived and used for post-publish validation.

Poem

🐰 A version is born in the tag,
Embedded by script without lag,
Tests verify true—
The flag -v rings through,
Now users need never to brag! 📦✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding a -v/--version flag that derives the version from git tags, which is the primary objective of this pull request.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch versioning

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

@tyom tyom merged commit 00c33a5 into main May 23, 2026
2 checks passed
@tyom tyom deleted the versioning branch May 23, 2026 19:38
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