Skip to content

feat: single source of truth for the version, enforced by CI - #23

Merged
chuckmeyer merged 1 commit into
mainfrom
feat/version-single-source
Aug 27, 2026
Merged

feat: single source of truth for the version, enforced by CI#23
chuckmeyer merged 1 commit into
mainfrom
feat/version-single-source

Conversation

@chuckmeyer

Copy link
Copy Markdown
Contributor

Problem

The package version and the release tags had drifted, silently, for three releases:

Said
tags v1.0.0, v1.1.0, v1.2.0, v1.3.0
pyproject.toml 0.1.0
User-Agent sent to Algolia algolia-agent-cli/0.1.0
algolia-agent --version did not exist

So pip show algolia-agent reported 0.1.0 for what was tagged v1.3.0, and every API request identified itself as a version that was never released.

Change

src/algolia_agent/__init__.py now holds __version__ and is the only place a version is written:

  • pyproject.toml reads it via [tool.setuptools.dynamic]
  • algolia-agent --version reports it
  • client.py builds _USER_AGENT from it (it was hardcoded in two places)

Verified all four agree after a reinstall:

$ algolia-agent --version
algolia-agent 1.3.0
  __version__        : 1.3.0
  User-Agent         : algolia-agent-cli/1.3.0
  installed metadata : 1.3.0

CI guard

A single source of truth still needs a manual bump, and forgetting it is precisely what happened three times. A new job runs on v* tag pushes and fails the build when the tag and __version__ disagree:

tag=1.3.0  __version__=1.3.0

The push trigger now includes tags: ["v*"] so that job can fire. The existing test matrix is unchanged.

Tests

167 pass (3 new): the semver shape of __version__, _USER_AGENT deriving from it, the header actually sent on a request (not just the constant), and agreement with installed package metadata.

Note on the existing v1.3.0 tag

v1.3.0 was pushed before this work and points at a commit where pyproject.toml still says 0.1.0 — so as it stands, the tag CI guard would have failed it. Two options, and it is a judgement call I have not made unilaterally:

  1. Re-cut v1.3.0 at the merge commit for this PR. The tag is minutes old, has no release object, and no consumers — so moving it is cheap, and it means v1.3.0 is the first release that reports itself correctly.
  2. Leave v1.3.0 as the last of the inaccurate ones and make v1.4.0 the first accurate release. Avoids moving a published tag on principle.

🤖 Generated with Claude Code

The package version drifted from the release tags: pyproject.toml said 0.1.0
across v1.0.0, v1.1.0 and v1.2.0, and the client sent
"algolia-agent-cli/0.1.0" in every request. There was also no way to ask the CLI
what version it was.

__version__ in src/algolia_agent/__init__.py is now the only place a version is
written. pyproject reads it via [tool.setuptools.dynamic], `--version` reports
it, and the client builds its User-Agent from it, so the four surfaces cannot
disagree.

A CI job on v* tag pushes compares the tag to __version__ and fails the build if
they differ, which is exactly the drift that went unnoticed for three releases.
The push trigger now includes tags so that job can run.

Tests cover the semver shape, the User-Agent constant, the header actually sent
on a request, and agreement with installed package metadata.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@chuckmeyer
chuckmeyer merged commit c08b846 into main Aug 27, 2026
4 checks passed
@chuckmeyer
chuckmeyer deleted the feat/version-single-source branch August 27, 2026 01:24
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