feat: single source of truth for the version, enforced by CI - #23
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The package version and the release tags had drifted, silently, for three releases:
v1.0.0,v1.1.0,v1.2.0,v1.3.0pyproject.toml0.1.0User-Agentsent to Algoliaalgolia-agent-cli/0.1.0algolia-agent --versionSo
pip show algolia-agentreported0.1.0for what was taggedv1.3.0, and every API request identified itself as a version that was never released.Change
src/algolia_agent/__init__.pynow holds__version__and is the only place a version is written:pyproject.tomlreads it via[tool.setuptools.dynamic]algolia-agent --versionreports itclient.pybuilds_USER_AGENTfrom it (it was hardcoded in two places)Verified all four agree after a reinstall:
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:The
pushtrigger now includestags: ["v*"]so that job can fire. The existing test matrix is unchanged.Tests
167 pass (3 new): the semver shape of
__version__,_USER_AGENTderiving 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.0was pushed before this work and points at a commit wherepyproject.tomlstill says0.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:v1.3.0at 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.v1.3.0as the last of the inaccurate ones and makev1.4.0the first accurate release. Avoids moving a published tag on principle.🤖 Generated with Claude Code