Add pre-commit hook to update version

This commit is contained in:
2023-01-05 21:10:17 +01:00
parent 8efce77062
commit 2807c5e00e
5 changed files with 39 additions and 11 deletions

13
.githooks/pre-commit Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -euo pipefail
echo "----------------"
echo "Pre-commit hooks"
echo "================"
VERSION_NUMBER=$(git describe --tags)
echo "Updating "VERSION_NUMBER" in Dockerfile to $VERSION_NUMBER"
sed -i "s/^ENV VERSION_NUMBER.*$/ENV VERSION_NUMBER ${VERSION_NUMBER}/" Dockerfile
echo "Updating "version" in pyproject.toml to $VERSION_NUMBER"
sed -i "s/^version = \".*\"$/version = \"${VERSION_NUMBER}\"/" pyproject.toml
git add Dockerfile
git add pyproject.toml
echo "----------------"