From 0d0c66d09069a8fd465a260711898f7a00ecc84d Mon Sep 17 00:00:00 2001 From: Daylin Morgan Date: Wed, 15 Mar 2023 15:16:12 -0500 Subject: [PATCH] build: add hook to set version in viv.py --- .pre-commit-config.yaml | 7 +++++++ scripts/bump-dev.sh | 5 +++++ src/viv/viv.py | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100755 scripts/bump-dev.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d6560c2..cae23bc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,3 +20,10 @@ repos: rev: 'v0.0.245' hooks: - id: ruff + - repo: local + hooks: + - id: set-version + language: script + name: sets __version__ in viv.py + entry: ./scripts/bump-dev.sh + files: viv.py$ diff --git a/scripts/bump-dev.sh b/scripts/bump-dev.sh new file mode 100755 index 0000000..84ac30c --- /dev/null +++ b/scripts/bump-dev.sh @@ -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 diff --git a/src/viv/viv.py b/src/viv/viv.py index 5e31522..d4be726 100755 --- a/src/viv/viv.py +++ b/src/viv/viv.py @@ -30,7 +30,7 @@ from pathlib import Path from textwrap import dedent, wrap from typing import Dict, List, Tuple -__version__ = "22.12a3" +__version__ = "22.12a3-34-g1e74ebf-dev" @dataclass