build: add hook to set version in viv.py

This commit is contained in:
Daylin Morgan 2023-03-15 15:16:12 -05:00
parent 1e74ebf413
commit 0d0c66d090
Signed by: daylin
GPG key ID: C1E52E7DD81DF79F
3 changed files with 13 additions and 1 deletions

View file

@ -20,3 +20,10 @@ repos:
rev: 'v0.0.245' rev: 'v0.0.245'
hooks: hooks:
- id: ruff - id: ruff
- repo: local
hooks:
- id: set-version
language: script
name: sets __version__ in viv.py
entry: ./scripts/bump-dev.sh
files: viv.py$

5
scripts/bump-dev.sh Executable file
View file

@ -0,0 +1,5 @@
#!/usr/bin/env sh
TAG=$(git describe --tags --always --dirty=-dev)
VERSION="${TAG#v}"
sed -i "s/__version__ = \".*\"/__version__ = \"$VERSION\"/g" src/viv/viv.py
git add src/viv/viv.py

View file

@ -30,7 +30,7 @@ from pathlib import Path
from textwrap import dedent, wrap from textwrap import dedent, wrap
from typing import Dict, List, Tuple from typing import Dict, List, Tuple
__version__ = "22.12a3" __version__ = "22.12a3-34-g1e74ebf-dev"
@dataclass @dataclass