Skip to content

Commit c7a0ae2

Browse files
统一版本来源并修正发布校验
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
1 parent 68183c5 commit c7a0ae2

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

.github/workflows/publish-pypi.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ jobs:
4444
4545
expected = "${{ inputs.expected_version }}"
4646
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
47-
declared = pyproject["project"]["version"]
48-
if declared != expected:
49-
raise SystemExit(f"Expected version {expected}, but pyproject version is {declared}.")
47+
dynamic = pyproject["project"].get("dynamic", [])
48+
version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
49+
if dynamic != ["version"]:
50+
raise SystemExit(f"Expected dynamic version metadata, got {dynamic!r}.")
51+
if version_attr != "code2skill.version.__version__":
52+
raise SystemExit(f"Unexpected dynamic version source: {version_attr}.")
5053
if __version__ != expected:
5154
raise SystemExit(f"Expected version {expected}, but runtime version is {__version__}.")
5255
PY

.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,12 @@ jobs:
4747
tag = "${{ github.ref_name }}"
4848
version = tag.removeprefix("v")
4949
pyproject = tomllib.loads((root / "pyproject.toml").read_text(encoding="utf-8"))
50-
declared = pyproject["project"]["version"]
51-
if declared != version:
52-
raise SystemExit(f"Tag {tag} does not match pyproject version {declared}.")
50+
dynamic = pyproject["project"].get("dynamic", [])
51+
version_attr = pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
52+
if dynamic != ["version"]:
53+
raise SystemExit(f"Expected dynamic version metadata, got {dynamic!r}.")
54+
if version_attr != "code2skill.version.__version__":
55+
raise SystemExit(f"Unexpected dynamic version source: {version_attr}.")
5356
if __version__ != version:
5457
raise SystemExit(f"Tag {tag} does not match runtime version {__version__}.")
5558
release_note = root / "docs" / "releases" / f"v{version}.md"

docs/release.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ python -m code2skill --version
4141
When cutting a new release:
4242

4343
1. Update `version` in `pyproject.toml`
44-
2. Update `__version__` in `src/code2skill/__init__.py`
44+
2. Update `__version__` in `src/code2skill/version.py`
4545
3. Add a new note in `docs/releases/`
4646
4. Update `CHANGELOG.md`
4747

@@ -65,7 +65,7 @@ Use `.github/workflows/publish-pypi.yml` only when you explicitly want to publis
6565
Recommended flow:
6666

6767
1. prepare and push the final release commit
68-
2. make sure the version in `pyproject.toml` and `src/code2skill/__init__.py` is final
68+
2. make sure `src/code2skill/version.py` has the final version and `pyproject.toml` still points to the dynamic version source
6969
3. run the `Release` workflow via a version tag so GitHub Release creation succeeds
7070
4. manually run `Publish PyPI` from the same ref and provide the exact version string
7171

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "code2skill"
7-
version = "0.1.6"
7+
dynamic = ["version"]
88
description = "Generate repository-aware Skills, blueprints, and AI rule files from real Python codebases."
99
readme = "README.md"
1010
requires-python = ">=3.10"
@@ -60,6 +60,9 @@ code2skill = "code2skill.cli:main"
6060
package-dir = {"" = "src"}
6161
include-package-data = false
6262

63+
[tool.setuptools.dynamic]
64+
version = {attr = "code2skill.version.__version__"}
65+
6366
[tool.setuptools.package-data]
6467
code2skill = ["py.typed"]
6568

tests/test_import_surfaces.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,9 @@ def test_package_includes_py_typed_marker() -> None:
111111
def test_runtime_version_matches_pyproject_metadata() -> None:
112112
pyproject = tomllib.loads((ROOT / "pyproject.toml").read_text(encoding="utf-8"))
113113

114-
assert pyproject["project"]["version"] == __version__
114+
assert pyproject["project"]["dynamic"] == ["version"]
115+
assert (
116+
pyproject["tool"]["setuptools"]["dynamic"]["version"]["attr"]
117+
== "code2skill.version.__version__"
118+
)
119+
assert __version__ == "0.1.7"

0 commit comments

Comments
 (0)