diff --git a/.github/workflows/publish-to-pypi.yml b/.github/workflows/publish-to-pypi.yml index 7c18650..733357a 100644 --- a/.github/workflows/publish-to-pypi.yml +++ b/.github/workflows/publish-to-pypi.yml @@ -12,6 +12,10 @@ jobs: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing steps: - uses: actions/checkout@v4.1.2 + with: + # Full history + tags so hatch-vcs derives the version from the + # release tag instead of falling back to a guessed version. + fetch-depth: 0 - name: Set up Python 3.11 uses: actions/setup-python@v5.0.0 with: @@ -24,4 +28,6 @@ jobs: pip install build python -m build - name: Publish release to PyPI - uses: pypa/gh-action-pypi-publish@v1.13.0 + # v1.14.x bundles twine 7, which accepts Metadata-Version 2.5 + # (v1.13.0 bundled twine 6.1 / packaging 25.0, which did not). + uses: pypa/gh-action-pypi-publish@v1.14.3 diff --git a/pyproject.toml b/pyproject.toml index 10d427c..2bbf267 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "ttn_client" -version = "1.3.0" +dynamic = ["version"] authors = [ { name="Angel Nunez Mencias", email="pypi@angelnu.com" }, ] @@ -21,5 +21,22 @@ Homepage = "https://github.com/angelnu/thethinksnetwork_python_client" Issues = "https://github.com/angelnu/thethinksnetwork_python_client/issues" [build-system] -requires = ["hatchling"] +requires = ["hatchling", "hatch-vcs"] build-backend = "hatchling.build" + +[tool.hatch.version] +source = "vcs" +# Fallback used when no git tag is reachable (e.g. shallow clones); the +# release workflow fetches the full history so tagged builds always win. +fallback-version = "0.0.0" + +# Keep the emitted core metadata at 2.4: hatchling >= 1.30 defaults to +# Metadata-Version 2.5, which is rejected by the twine bundled in +# pypa/gh-action-pypi-publish < 1.14 (twine < 7). Pinning the emitted +# metadata version is deterministic, unlike pinning hatchling itself +# (its defaults are not monotonic: 1.30 -> 2.5, 1.31 -> 2.4, 1.32 -> 2.5). +[tool.hatch.build.targets.wheel] +core-metadata-version = "2.4" + +[tool.hatch.build.targets.sdist] +core-metadata-version = "2.4"