Skip to content

Commit 7e9e856

Browse files
authored
Merge pull request #56 from awslabs/feat/setuptools-scm-versioning
build: derive version from git tags via setuptools-scm
2 parents ba693f8 + 81a6bae commit 7e9e856

5 files changed

Lines changed: 39 additions & 23 deletions

File tree

.github/workflows/publish.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
contents: read
1414
steps:
1515
- uses: actions/checkout@v4
16+
with:
17+
# setuptools-scm needs full history + tags to derive the version
18+
# from the latest v* tag. Default checkout depth=1 hides them.
19+
fetch-depth: 0
1620

1721
- uses: actions/setup-node@v4
1822
with:
@@ -27,12 +31,10 @@ jobs:
2731
- name: Install uv
2832
uses: astral-sh/setup-uv@v4
2933

30-
- name: Set version from tag and sync lockfile
34+
- name: Verify tag matches the commit
3135
run: |
3236
TAG="${GITHUB_REF#refs/tags/v}"
33-
echo "Setting version to $TAG"
34-
sed -i "s/^version = .*/version = \"$TAG\"/" pyproject.toml
35-
uv lock
37+
echo "Building for tag v$TAG (setuptools-scm will derive version from git)"
3638
3739
- name: Build viewer frontend
3840
run: |

AGENTS.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,24 @@ Update both files:
2525

2626
## Releasing
2727

28+
The version lives in git tags. `pyproject.toml` has no `version` field —
29+
`setuptools-scm` derives it from the latest `v*` tag at build time.
30+
2831
After merging a PR with user-visible changes, publish to PyPI from main:
2932

3033
```bash
3134
git checkout main && git pull
32-
make release # patch bump (0.3.0 → 0.3.1) — bug fixes only
33-
make release-minor # minor bump (0.3.0 → 0.4.0) — new features, backwards-compat
34-
make release-major # major bump (0.3.0 → 1.0.0) — breaking changes
35+
make release # patch bump (0.3.4 → 0.3.5) — bug fixes only
36+
make release-minor # minor bump (0.3.4 → 0.4.0) — new features, backwards-compat
37+
make release-major # major bump (0.3.4 → 1.0.0) — breaking changes
3538
```
3639

37-
Each target bumps `pyproject.toml`, commits, tags `vX.Y.Z`, and pushes.
38-
The `publish.yml` GitHub workflow takes over from the tag push and
39-
publishes to PyPI via trusted publisher. Don't tag manually.
40+
Each target reads the latest tag, computes the next, tags it, and pushes
41+
the tag. No source file is bumped; no "Release vX.Y.Z" commits land on
42+
main. The `publish.yml` workflow runs on tag push and publishes to PyPI
43+
via trusted publisher (setuptools-scm bakes the tag's version into the
44+
built artifacts).
4045

4146
Pick the bump from semver: new public API = minor, only bug fixes =
42-
patch, backwards-incompatible = major.
47+
patch, backwards-incompatible = major. Don't tag manually outside the
48+
Makefile — the targets enforce clean tree + on main + up-to-date.

Makefile

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,19 @@ build: ## Build all images
4747
clean: stop ## Stop and remove volumes
4848
@$(COMPOSE) down -v
4949

50-
release: ## Bump patch version, tag, and push (triggers PyPI publish)
50+
release: ## Tag a patch release and push (triggers PyPI publish)
5151
@$(MAKE) _release BUMP=patch
5252

53-
release-minor: ## Bump minor version, tag, and push
53+
release-minor: ## Tag a minor release and push
5454
@$(MAKE) _release BUMP=minor
5555

56-
release-major: ## Bump major version, tag, and push
56+
release-major: ## Tag a major release and push
5757
@$(MAKE) _release BUMP=major
5858

59+
# Version lives in git tags. We read the latest v* tag, bump the requested
60+
# component, push the new tag — and that's it. No source edits, no
61+
# "Release vX.Y.Z" commits. The publish.yml workflow runs on tag push and
62+
# setuptools-scm reads the version straight from the tag at build time.
5963
_release:
6064
@if [ -n "$$(git status --porcelain)" ]; then \
6165
echo "Working tree is dirty. Commit or stash first."; exit 1; \
@@ -64,15 +68,13 @@ _release:
6468
echo "Release must be run from main (currently on $$(git rev-parse --abbrev-ref HEAD))."; exit 1; \
6569
fi
6670
@git pull --ff-only origin main
67-
@OLD=$$(python3 -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])") && \
71+
@git fetch --tags origin
72+
@OLD=$$(git tag -l 'v*' | sed 's/^v//' | sort -V | tail -n1) && \
73+
if [ -z "$$OLD" ]; then OLD="0.0.0"; fi && \
6874
NEW=$$(python3 -c "v='$$OLD'.split('.'); part='$(BUMP)'; \
6975
idx={'major':0,'minor':1,'patch':2}[part]; v[idx]=str(int(v[idx])+1); \
7076
[v.__setitem__(i,'0') for i in range(idx+1,3)]; print('.'.join(v))") && \
71-
echo "Bumping $$OLD -> $$NEW" && \
72-
python3 -c "import re,pathlib; p=pathlib.Path('pyproject.toml'); p.write_text(re.sub(r'^version = \".*\"', 'version = \"'+'$$NEW'+'\"', p.read_text(), count=1, flags=re.M))" && \
73-
git add pyproject.toml && \
74-
git commit -m "Release v$$NEW" && \
77+
echo "Releasing v$$NEW (previous: v$$OLD)" && \
7578
git tag "v$$NEW" && \
76-
git push origin main && \
7779
git push origin "v$$NEW" && \
7880
echo "Pushed v$$NEW. Watch https://github.com/awslabs/llm-evaluation-system/actions"

pyproject.toml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "llm-evaluation-system"
3-
version = "0.3.0"
3+
dynamic = ["version"]
44
description = "MCP server for agentic LLM evaluation: jury scoring, agent tracing via OpenTelemetry, document-grounded QA generation, PDF reports."
55
readme = "README.md"
66
requires-python = ">=3.12,<3.15"
@@ -83,9 +83,16 @@ eval-mcp = "eval_mcp.cli:main"
8383
eval-chat = "backend.core.main:main"
8484

8585
[build-system]
86-
requires = ["setuptools>=68.0.0", "wheel"]
86+
requires = ["setuptools>=68.0.0", "setuptools-scm>=8.0.0", "wheel"]
8787
build-backend = "setuptools.build_meta"
8888

89+
[tool.setuptools_scm]
90+
# Version is derived from the latest `v*` git tag. When building on a tagged
91+
# commit the version is clean (e.g. "0.3.5"); off-tag commits get a dev
92+
# version (e.g. "0.3.6.dev3+gabc1234"). `fallback_version` covers sdist
93+
# builds and shallow clones where git history isn't available.
94+
fallback_version = "0.0.0+unknown"
95+
8996
[tool.setuptools.packages.find]
9097
where = ["."]
9198
include = ["backend*", "eval_mcp*"]

uv.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)