Skip to content

Commit 63424b9

Browse files
committed
Switch to dynamic versioning from Git tags
- Use hatch-vcs for automatic version detection from Git tags - Remove hardcoded version from pyproject.toml - Add __version__ export to jqueue module - Update release workflow to fetch full git history for versioning - Add _version.py to .gitignore (auto-generated file) This fixes the PyPI 'file already exists' error by ensuring each release gets a unique version from its Git tag.
1 parent cff06f4 commit 63424b9

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ jobs:
6060
id-token: write # required for OIDC trusted publishing
6161
steps:
6262
- uses: actions/checkout@v4
63+
with:
64+
fetch-depth: 0 # Required for hatch-vcs to access git history
6365

6466
- name: Install uv
6567
uses: astral-sh/setup-uv@v5

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ dist/
1515
build/
1616
*.egg-info/
1717
*.egg
18+
jqueue/_version.py
1819

1920
# uv
2021
.uv/

jqueue/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,14 @@ async def write(content, if_match=None) -> str
7373
from jqueue.domain.models import Job, JobStatus, QueueState
7474
from jqueue.ports.storage import ObjectStoragePort
7575

76+
try:
77+
from jqueue._version import __version__
78+
except ImportError:
79+
__version__ = "0.0.0+unknown"
80+
7681
__all__ = [
82+
# Version
83+
"__version__",
7784
# Domain models
7885
"Job",
7986
"JobStatus",

pyproject.toml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[build-system]
2-
requires = ["hatchling"]
2+
requires = ["hatchling", "hatch-vcs"]
33
build-backend = "hatchling.build"
44

55
[project]
66
name = "jqueue"
7-
version = "0.1.0"
7+
dynamic = ["version"]
88
description = "Storage-agnostic job queue using object storage with compare-and-set semantics"
99
readme = "README.md"
1010
license = { text = "MIT" }
@@ -57,6 +57,16 @@ python_version = "3.12"
5757
module = ["aioboto3", "aioboto3.*", "google.cloud.storage", "google.cloud.*", "google.api_core", "google.api_core.*"]
5858
ignore_missing_imports = true
5959

60+
[[tool.mypy.overrides]]
61+
module = ["jqueue._version"]
62+
ignore_missing_imports = true
63+
6064
[[tool.mypy.overrides]]
6165
module = ["tests.*"]
6266
disallow_untyped_defs = false
67+
68+
[tool.hatch.version]
69+
source = "vcs"
70+
71+
[tool.hatch.build.hooks.vcs]
72+
version-file = "jqueue/_version.py"

0 commit comments

Comments
 (0)