Skip to content

Derive release versions from tags#64

Merged
ChiragAgg5k merged 2 commits into
mainfrom
chore/tag-driven-release-versioning
Jul 7, 2026
Merged

Derive release versions from tags#64
ChiragAgg5k merged 2 commits into
mainfrom
chore/tag-driven-release-versioning

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Summary

  • Derive Python package versions from Git release tags with Hatch VCS instead of hardcoding versions in pyproject.toml.
  • Generate MCP Registry metadata from server.template.json during publish so server.json is no longer manually maintained.
  • Resolve runtime server version from installed package metadata and pass explicit package versions into Docker builds where Git metadata is unavailable.

Testing

  • uv run --group dev black --check src tests scripts
  • uv run --group dev ruff check src tests scripts
  • uv run --group dev pyright
  • uv run python -m unittest discover -s tests/unit -v
  • uv run python scripts/render_server_json.py 0.8.8
  • uv build
  • docker build --build-arg PACKAGE_VERSION=0.8.8 -t appwrite-mcp:test .

@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown

Greptile Summary

This PR eliminates manual version bookkeeping by deriving the Python package version from Git tags via hatch-vcs, auto-generating server.json from a template during publish, and resolving the runtime SERVER_VERSION from installed package metadata. All three previously error-prone sync points (pyproject.toml ↔ server.json ↔ constants.py) are now driven from a single source of truth.

  • VCS versioning: pyproject.toml moves to dynamic = [\"version\"] with hatch-vcs; Docker builds inject PACKAGE_VERSION as SETUPTOOLS_SCM_PRETEND_VERSION so the Git-free build context still resolves a valid version.
  • Registry metadata generation: server.template.json replaces server.json in version control; scripts/render_server_json.py stamps the tag-derived version into both the top-level and package-entry fields before the mcp-publisher step runs.
  • Runtime version: constants.SERVER_VERSION is now read from importlib.metadata with a graceful fallback, and unit tests cover both the happy path and the PackageNotFoundError fallback.

Confidence Score: 5/5

Safe to merge — the change removes manual multi-file version sync in favour of a well-understood VCS + env-var pattern, and all three new code paths are covered by unit tests.

All changed files are clean: the hatch-vcs/SETUPTOOLS_SCM_PRETEND_VERSION wiring is correct (the env var is honoured by hatch-vcs for Git-free builds), the render script uses JSON parse-and-replace rather than fragile string substitution, and the workflow tag-format guard is consistent across both the publish and registry jobs. No correctness issues were found.

No files require special attention.

Important Files Changed

Filename Overview
pyproject.toml Switches from hardcoded version = "0.8.7" to dynamic = ["version"] with hatch-vcs as the VCS-based version source; build-system deps updated accordingly.
Dockerfile Adds ARG PACKAGE_VERSION=0.0.0+docker and exports it as SETUPTOOLS_SCM_PRETEND_VERSION so hatch-vcs can determine the package version in Git-free Docker builds; correctly placed before the uv sync step.
scripts/render_server_json.py New script that reads server.template.json, stamps the version into both the top-level version and the matching packages[].version fields, and writes server.json; uses for…else correctly to guard against a missing package identifier.
server.template.json Renamed from server.json, with hardcoded version strings replaced by __VERSION__ placeholders; used as the source for render_server_json.py.
src/mcp_server_appwrite/constants.py Replaces hardcoded SERVER_VERSION = "0.8.6" with a dynamic lookup via importlib.metadata, falling back to "0.0.0+unknown" when the package is not installed; correctly exposes importlib_metadata as a module-level name for test patching.
.github/workflows/publish.yml Replaces the fragile multi-file version sync check with a tag-format guard; adds Python setup and the render_server_json.py call to the publish-mcp-registry job; fetch-depth: 0 is now set so hatch-vcs can read the full tag history.
.github/workflows/production.yml Adds a Derive package version step that strips the v prefix from the release tag and passes it as PACKAGE_VERSION build-arg; falls back to 0.0.0+${GITHUB_SHA} for non-release triggers.
.github/workflows/staging.yml Passes PACKAGE_VERSION=0.0.0+${{ github.sha }} as a Docker build-arg so the staged image reports a deterministic version string.
.github/workflows/ci.yml Adds --build-arg PACKAGE_VERSION=0.0.0+ci to the CI Docker build so hatch-vcs is not invoked without a Git context.
tests/unit/test_release_metadata.py New unit tests covering server version resolution (happy path and fallback) and the render script (version stamping and invalid version rejection); uses dynamic module loading to test the standalone script.
.gitignore Adds server.json to .gitignore since it is now a generated artifact rather than a tracked file.
AGENTS.md Updates release metadata guidance to reflect the VCS-driven versioning workflow and remove the now-obsolete manual sync instructions.
uv.lock Removes the pinned version = "0.8.7" from the local editable package entry; expected change when switching to dynamic VCS versioning.

Reviews (2): Last reviewed commit: "Address release workflow review feedback" | Re-trigger Greptile

Comment thread .github/workflows/publish.yml Outdated
Comment thread .github/workflows/publish.yml
@ChiragAgg5k ChiragAgg5k merged commit f3864a2 into main Jul 7, 2026
5 checks passed
@ChiragAgg5k ChiragAgg5k deleted the chore/tag-driven-release-versioning branch July 7, 2026 10:23
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