Skip to content

Commit eecda7c

Browse files
authored
Merge pull request #445 from jernst/develop
Implement better versioning scheme
2 parents bfda1f7 + 7860089 commit eecda7c

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ release :
7070
[[ -d venv.release ]] && rm -rf venv.release || true
7171
[[ -d dist ]] && rm -rf dist || true
7272
$(PYTHON) -mvenv venv.release
73-
venv.release/bin/pip install twine
74-
venv.release/bin/pip install --upgrade build
75-
venv.release/bin/python -m build
73+
FEDITEST_RELEASE_VERSION=y venv.release/bin/pip install twine
74+
FEDITEST_RELEASE_VERSION=y venv.release/bin/pip install --upgrade build
75+
FEDITEST_RELEASE_VERSION=y venv.release/bin/python -m build
7676
@echo WARNING: YOU ARE NOT DONE YET
7777
@echo The actual push to pypi.org you need to do manually. Enter:
7878
@echo venv.release/bin/twine upload dist/*

hatch_build.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# Set a dynamic version number, see https://hatch.pypa.io/dev/how-to/config/dynamic-metadata/
3+
# At release time, override with env var: FEDITEST_RELEASE_VERSION=y
4+
#
5+
6+
from datetime import datetime
7+
import os
8+
9+
from hatchling.metadata.plugin.interface import MetadataHookInterface
10+
11+
12+
class JSONMetaDataHook(MetadataHookInterface):
13+
def update(self, metadata):
14+
if 'FEDITEST_RELEASE_VERSION' in os.environ and os.environ['FEDITEST_RELEASE_VERSION'].lower() == 'y':
15+
metadata['version'] = metadata['base_version']
16+
else:
17+
metadata['version'] = metadata['base_version'] + '.dev' + datetime.now().strftime("%Y%m%d%H%M%S")

pyproject.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ build-backend = "hatchling.build"
55

66
[project]
77
name = "feditest"
8-
version = "0.5"
8+
base_version = "0.6"
9+
dynamic = ["version"]
910
authors = [
1011
{ name="Johannes Ernst", email="git@j12t.org" },
1112
{ name="Steve Bate", email="svc-github@stevebate.net" }
@@ -62,6 +63,9 @@ exclude = [
6263
"docs/"
6364
]
6465

66+
[tool.hatch.metadata.hooks.custom]
67+
# Empty: https://hatch.pypa.io/dev/how-to/config/dynamic-metadata/
68+
6569
[tool.pylint."MESSAGES CONTROL"]
6670
max-line-length=120
6771
disable="arguments-renamed, empty-docstring, global-variable-not-assigned, line-too-long, missing-class-docstring, missing-function-docstring, too-few-public-methods, too-many-arguments"

0 commit comments

Comments
 (0)