Skip to content

Commit 89273f9

Browse files
Merge pull request #167 from GNS-Science/chore/hatch-vcs
- hatch-vcs for dynamic versioning from git tag (v*) - updated nzhsm-model version to allow disaggregation configs to be verified
2 parents c92f74f + e223376 commit 89273f9

9 files changed

Lines changed: 351 additions & 377 deletions

File tree

.bumpversion.cfg

Lines changed: 0 additions & 28 deletions
This file was deleted.

.githooks/pre-push

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Prevent pushing a version tag unless the changelog has a matching entry.
5+
# Override defaults via env vars: CHANGELOG_PATH, TAG_PREFIX
6+
CHANGELOG_PATH="${CHANGELOG_PATH:-CHANGELOG.md}"
7+
TAG_PREFIX="${TAG_PREFIX:-v}"
8+
9+
while read -r local_ref local_sha remote_ref remote_sha; do
10+
case "${local_ref}" in
11+
refs/tags/${TAG_PREFIX}*)
12+
version="${local_ref#refs/tags/${TAG_PREFIX}}"
13+
if ! grep -qE "^## \[${version}\]" "${CHANGELOG_PATH}"; then
14+
echo "ERROR: ${CHANGELOG_PATH} is missing a '## [${version}]' section for tag ${local_ref#refs/tags/}." >&2
15+
echo "Update ${CHANGELOG_PATH}, delete the tag (git tag -d ${local_ref#refs/tags/}), commit, and re-tag." >&2
16+
exit 1
17+
fi
18+
;;
19+
esac
20+
done
21+
22+
exit 0

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,7 @@ audit.txt
123123
.safety-project.ini
124124

125125
# LLM session state
126-
.llm/.session
126+
.llm/.session
127+
128+
# generated by hatch-vcs at build / editable-install time
129+
toshi_hazard_store/_version.py

CHANGELOG.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
# Changelog
22

3-
## [2.0.0] Unreleased
3+
## [2.0.1] 2026-05-11
4+
### Added
5+
- hatch-vcs for dynamic versioning from git tag (v*)
6+
- git hook to enforce git version tag has matching CHANGLOG entry
7+
8+
### Changed
9+
- updated nzhsm-model version to allow disaggregation configs to be verified
10+
- `nzshm-model` updated to 0.15.2
11+
12+
### Removed
13+
- bump2version dev dependency
14+
15+
## [2.0.0] 2026-05-06
416

517
### Added
618
- Import disaggregation realizations from OpenQuake

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ uv run tox -e lint # ruff check + mypy only
1919
### Build & Release
2020
```bash
2121
uv build
22-
bump2version patch # updates pyproject.toml, __init__.py, creates git tag
22+
git tag vX.Y.Z # replace X.Y.Z with the new version; version derived from tag by hatch-vcs
2323
git push && git push --tags # triggers PyPI publish via GitHub Actions
2424
```
2525

@@ -111,7 +111,7 @@ Any new dependency that calls AWS at import time must be accounted for here.
111111

112112
1. Ensure tests pass and `poetry run tox -e format,lint` passes
113113
2. Update `CHANGELOG.md` with version header (e.g. `## [1.4.1] 2026-02-24`)
114-
3. `bump2version patch` (or `minor`/`major`) — commits + tags automatically
114+
3. `git tag vX.Y.Z` (then `git push --tags`) — version is derived from the tag by hatch-vcs
115115
4. `git push && git push --tags` — GitHub Actions publishes to PyPI
116116

117117
## Documentation Conventions

CONTRIBUTING.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,8 @@ Make sure all your changes are committed (including an entry in CHANGELOG.md).
115115
Then run:
116116
117117
```
118-
$ uv run bump2version patch # possible: major / minor / patch
119-
$ git push
120-
$ git push --tags
118+
$ git tag vX.Y.Z # replace X.Y.Z with the new version
119+
$ git push && git push --tags
121120
```
122121
123122
GitHub Actions will then deploy to PyPI if tests pass.

pyproject.toml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "toshi-hazard-store"
3-
version = "2.0.0"
3+
dynamic = ["version"]
44

55
homepage = "https://github.com/GNS-Science/toshi-hazard-store"
66
description = "Library for saving and retrieving NZHSM openquake hazard results with convenience (uses pyarrow with parquet format)."
@@ -27,7 +27,7 @@ dependencies = [
2727
"nshm-toshi-client>=1.0.1",
2828
"numpy>=1.24",
2929
"nzshm-common>=0.8.4",
30-
"nzshm-model>=0.13.6",
30+
"nzshm-model>=0.15.2",
3131
"pandas>=2,<3",
3232
"pathy>=0.11.0",
3333
"pyarrow>=20.0.0",
@@ -79,7 +79,6 @@ doc = [
7979
]
8080

8181
dev = [
82-
"bump2version>=1.0.1",
8382
"ipython>=8.11.0",
8483
"matplotlib>=3.6.3",
8584
"moto>=4",
@@ -131,5 +130,11 @@ exclude-newer = "1 week"
131130
exclude-newer-package = {"nzshm-common" = false, "nzshm-model" = false, "nshm-toshi-client" = false}
132131

133132
[build-system]
134-
requires = ["hatchling"]
133+
requires = ["hatchling", "hatch-vcs"]
135134
build-backend = "hatchling.build"
135+
136+
[tool.hatch.version]
137+
source = "vcs"
138+
139+
[tool.hatch.build.hooks.vcs]
140+
version-file = "toshi_hazard_store/_version.py"

toshi_hazard_store/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
__author__ = """GNS Science"""
44
__email__ = 'nshm@gns.cri.nz'
5-
__version__ = '2.0.0'
6-
7-
85
import toshi_hazard_store.model as model
96
import toshi_hazard_store.query.hazard_query as query_v3 # alias for clients using deprecated module name
7+
8+
from ._version import __version__

0 commit comments

Comments
 (0)